Меню

08001 ошибка при попытке подсоединения java io eofexception

All right—I’ve figured it out.

First off, @Mark B was right—the issue was that I hadn’t yet made the database itself publicly accessible via the VPC security group of which it was a member. To do this, from the database detail screen in AWS, I:

  1. clicked (what for me was the one and only) link beneath the «VPC security groups» of the database’s dashboard, which directed me to the EC2 Security Groups screen
  2. clicked the security group link related to my database, which directed me to that group’s detail page
  3. clicked the «Edit inbound rules» button which directed me to the «Edit inbound rules» screen
  4. clicked the «Add rule» button, which caused a table row containing the following columns: «Type», «Protocol,» «Port Range,» «Source,» «Description — optional»
  5. selected «PostgreSQL» for the «Type» column, which caused the values of «TCP» and «5432» to populate the «Protocol» and «Port range» columns respectively, entered my machine’s IP address («123.456.789.012/32»—no quotes and no parentheses), and left «Description — optional» blank, because, well, it’s optional.

Finally, I guess I’d forgotten to explicitly name the database, and so my attempts to enter what for me was ostensibly the database’s name (that is, «database-1») resulted in a connection error indicating that «database-1» does not exist. So, for the sake of ease and simply verifying my database connection, I entered «postgres» as the database name in my database client (I’m presently using DataGrip), because «postgres» is the de facto name of a postgreSQL database.

And that should work. I’m sure this is all no-brainer stuff to those more experienced with AWS, but it’s new to me and presumably to many others.

Thanks again, @Mark B, for sending me down the right path.

All right—I’ve figured it out.

First off, @Mark B was right—the issue was that I hadn’t yet made the database itself publicly accessible via the VPC security group of which it was a member. To do this, from the database detail screen in AWS, I:

  1. clicked (what for me was the one and only) link beneath the «VPC security groups» of the database’s dashboard, which directed me to the EC2 Security Groups screen
  2. clicked the security group link related to my database, which directed me to that group’s detail page
  3. clicked the «Edit inbound rules» button which directed me to the «Edit inbound rules» screen
  4. clicked the «Add rule» button, which caused a table row containing the following columns: «Type», «Protocol,» «Port Range,» «Source,» «Description — optional»
  5. selected «PostgreSQL» for the «Type» column, which caused the values of «TCP» and «5432» to populate the «Protocol» and «Port range» columns respectively, entered my machine’s IP address («123.456.789.012/32»—no quotes and no parentheses), and left «Description — optional» blank, because, well, it’s optional.

Finally, I guess I’d forgotten to explicitly name the database, and so my attempts to enter what for me was ostensibly the database’s name (that is, «database-1») resulted in a connection error indicating that «database-1» does not exist. So, for the sake of ease and simply verifying my database connection, I entered «postgres» as the database name in my database client (I’m presently using DataGrip), because «postgres» is the de facto name of a postgreSQL database.

And that should work. I’m sure this is all no-brainer stuff to those more experienced with AWS, but it’s new to me and presumably to many others.

Thanks again, @Mark B, for sending me down the right path.

Creating my container as:

public static PostgreSQLContainer<?> container = new PostgreSQLContainer<>("postgres:latest");

static {
    container.start();

    System.setProperty("driver-class-name", container.getDriverClassName());
    System.setProperty("spring.datasource.url", container.getJdbcUrl());
    System.setProperty("spring.datasource.username", container.getUsername());
    System.setProperty("spring.datasource.password", container.getPassword());
}

I’m trying to enter debug mode after start and check connection, however I keep getting

[08001] The connection attempt failed. java.io.EOFException.

Full exception trace:

org.postgresql.util.PSQLException: The connection attempt failed.

    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
    at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:211)
    at org.postgresql.Driver.makeConnection(Driver.java:458)
    at org.postgresql.Driver.connect(Driver.java:260)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at com.lenovo.edge.controller.UploadControllerTest.whenSelectQueryExecuted_thenResulstsReturned(UploadControllerTest.java:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused by: java.io.EOFException
    at org.postgresql.core.PGStream.receiveChar(PGStream.java:337)
    at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:411)
    at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:135)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
    ... 29 more

So it’s pretty obvious that my application cannot connect to it as well.

Any suggestions?

asked Feb 21, 2020 at 11:05

Tyulpan Tyulpan's user avatar

Tyulpan TyulpanTyulpan Tyulpan

7141 gold badge7 silver badges17 bronze badges

7

Answering my own question, the problem was container was not able to receive connections, I’m not sure actually why, cos config looks fine for me, but working solution is to initialize container as https://www.testcontainers.org/modules/databases/#database-containers-launched-via-jdbc-url-scheme

So here is example of working solution for me, hope it can help to somebody:

@ActiveProfiles("test")
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
  "spring.datasource.url=jdbc:tc:postgresql:12.2:///test?TC_INITSCRIPT=init.sql",
  "spring.datasource.driver-class-name=org.testcontainers.jdbc.ContainerDatabaseDriver"
})
abstract class AbstractIntegrationTestCase {

  public static GenericContainer<?> container = new PostgreSQLContainer<>("postgres:12.2");

  static {
    container.start();
  }

  @Autowired
  protected TestRestTemplate restTemplate;
}

answered Feb 24, 2020 at 8:13

Tyulpan Tyulpan's user avatar

Tyulpan TyulpanTyulpan Tyulpan

7141 gold badge7 silver badges17 bronze badges

Когда я пытаюсь подключиться к экземпляру базы данных PostgreSQL, которую я создал согласно руководству AWS «Создание и подключение к базе данных PostgreSQL с Amazon RDS», расположенному здесь ( https://aws.amazon.com/getting-started/tutorials/create-connect-postgresql-db/ ), Я получаю сообщение об ошибке:

[08001] Попытка подключения не удалась. java.net.SocketTimeoutException: время ожидания подключения истекло.

База данных настроена на разрешение входящего и исходящего трафика на всех портах и ​​со всех IP-адресов. Я совершенно не понимаю, как заставить это работать, и обратился в службу поддержки AWS за их предложениями, но пока что все, что я сделал, — это следовал инструкциям, предписанным в руководстве по AWS, — безрезультатно.

Кто-нибудь знает, в чем может быть проблема?

Изменить: я должен упомянуть, что весь мой URL-адрес хоста, номер порта, имя базы данных и т. Д. Были правильно введены в DataGrip, поэтому ни одна из вышеперечисленных проблем не является проблемой.

1 ответ

Лучший ответ

Хорошо — я понял.

Во-первых, @Mark B был прав — проблема заключалась в том, что я еще не сделал саму базу данных общедоступной через группу безопасности VPC, членом которой он был. Для этого на подробном экране базы данных в AWS я:

  1. нажал (что для меня было единственной) ссылку под «Группы безопасности VPC» на панели управления базы данных, которая направила меня на экран «Группы безопасности EC2»
  2. щелкнул ссылку группы безопасности, относящуюся к моей базе данных, которая направила меня на страницу сведений об этой группе
  3. нажал кнопку «Изменить правила для входящих подключений», которая направила меня на экран «Изменить правила для входящих подключений».
  4. нажал кнопку «Добавить правило», в результате чего появилась строка таблицы, содержащая следующие столбцы: «Тип», «Протокол», «Диапазон портов», «Источник», «Описание — необязательно»
  5. выбрал «PostgreSQL» для столбца «Тип», в результате чего значения «TCP» и «5432» заняли соответственно столбцы «Протокол» и «Диапазон портов», ввел IP-адрес моей машины («123.456.789.012/32» — без кавычек и скобок) и оставил поле «Описание — необязательно» пустым, потому что это необязательно.

Наконец, я думаю, что забыл явно назвать базу данных, и поэтому мои попытки ввести то, что для меня было якобы именем базы данных (то есть «база данных-1»), привели к ошибке соединения, указывающей, что «база данных-1» не существует. Итак, для простоты и простой проверки подключения к базе данных я ввел «postgres» в качестве имени базы данных в моем клиенте базы данных (в настоящее время я использую DataGrip), потому что «postgres» — это фактическое имя базы данных postgreSQL.

И это должно сработать. Я уверен, что это несложно для тех, кто более опытен с AWS, но это ново для меня и, предположительно, для многих других.

Еще раз спасибо, @Mark B, за то, что направил меня по правильному пути.


2

Michael P.
11 Дек 2020 в 01:52

Problem

When using PostgreSQL in the DQIT Web Application, we have encountered the following error:

Message: java.io.EOFExceptionDetails:
java.io.EOFException
	at com.ataccama.dqc.commons.serialize.Serialize.read(Serialize.java:497)
	at com.ataccama.dqc.commons.serialize.Serialize.deserializeString(Serialize.java:387)
	at com.ataccama.epp.internal.core.data.db.dao.DbIssueBean.loadCustomAttrs(DbIssueBean.java:407)
	at com.ataccama.epp.internal.core.data.db.dao.IssueDao.makeIssue(IssueDao.java:172)
	at com.ataccama.epp.internal.core.data.db.dao.IssueDao.findIssues(IssueDao.java:234)
	...
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

Solution

This exception is caused by an outdated PostgreSQL JDBC driver used to connect to the PostgreSQL database. To resolve the problem, download and install the latest version of the PostgreSQL JDBC driver for the particular version of the PostgreSQL database. The version of the PostgreSQL database is displayed under the Properties tab when you click on the database connection under File Explorer > Databases > [Connection name] See the screenshot below.


Related articles

Hello,

i’m unable to connect to a postgres database through ssh tunnel. The connection is established and authentication succeeded but i’m disconnected. Here is the stacktrace :

2017-01-17 16:40:27.585 — DBeaver 3.8.3 is starting
2017-01-17 16:40:27.588 — Install path: ‘file:/C:/Program Files/dbeaver/’
2017-01-17 16:40:27.588 — Instance path: ‘file:/C:/Users/dimitri/.dbeaver/’
2017-01-17 16:40:27.590 — Memory available 123Mb/1796Mb
2017-01-17 16:40:27.594 — Starting RMI server at 59302
2017-01-17 16:40:27.646 — Initialize display
2017-01-17 16:40:28.774 — Initializing DBeaver 3.8.3
2017-01-17 16:40:28.778 — Host plugin: org.jkiss.dbeaver.core.application 3.8.3
2017-01-17 16:40:28.781 — Initialize Core…
2017-01-17 16:40:28.946 — Core initialized (165ms)
2017-01-17 16:40:28.949 — Configure workbench window
2017-01-17 16:40:29.023 — Create actions
2017-01-17 16:40:29.368 — Initialize workbench window
2017-01-17 16:40:29.387 — Finish initialization
2017-01-17 16:40:30.555 — Connect with ‘PostgreSQL — test’ (postgres-jdbc-1598c9d3ea8-43254cdf6a1bbb1)
2017-01-17 16:40:30.727 — Connected (postgres-jdbc-1598c9d3ea8-43254cdf6a1bbb1)
2017-01-17 16:40:36.691 — Connect with ‘jdbc:postgresql://dev.server.local:5432/test’ (postgres-jdbc-15996e6e5d1-88ac6223155bb8dc)
2017-01-17 16:40:36.810 — Instantiate SSH tunnel
2017-01-17 16:40:36.817 — Connect to tunnel host
2017-01-17 16:40:36.818 — SSH INFO: Connecting to dev.server.local port 22
2017-01-17 16:40:36.822 — SSH INFO: Connection established
2017-01-17 16:40:36.839 — SSH INFO: Remote version string: SSH-2.0-OpenSSH_6.6.1
2017-01-17 16:40:36.840 — SSH INFO: Local version string: SSH-2.0-JSCH-0.1.53
2017-01-17 16:40:36.842 — SSH INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
2017-01-17 16:40:36.859 — SSH INFO: aes256-ctr is not available.
2017-01-17 16:40:36.860 — SSH INFO: aes192-ctr is not available.
2017-01-17 16:40:36.861 — SSH INFO: aes256-cbc is not available.
2017-01-17 16:40:36.862 — SSH INFO: aes192-cbc is not available.
2017-01-17 16:40:36.863 — SSH INFO: CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
2017-01-17 16:40:36.902 — SSH INFO: CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
2017-01-17 16:40:36.906 — SSH INFO: SSH_MSG_KEXINIT sent
2017-01-17 16:40:36.907 — SSH INFO: SSH_MSG_KEXINIT received
2017-01-17 16:40:36.908 — SSH INFO: kex: server: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
2017-01-17 16:40:36.911 — SSH INFO: kex: server: ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
2017-01-17 16:40:36.913 — SSH INFO: kex: server: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
2017-01-17 16:40:36.917 — SSH INFO: kex: server: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
2017-01-17 16:40:36.922 — SSH INFO: kex: server: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
2017-01-17 16:40:36.928 — SSH INFO: kex: server: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
2017-01-17 16:40:36.934 — SSH INFO: kex: server: none,zlib@openssh.com
2017-01-17 16:40:36.936 — SSH INFO: kex: server: none,zlib@openssh.com
2017-01-17 16:40:36.937 — SSH INFO: kex: server:
2017-01-17 16:40:36.938 — SSH INFO: kex: server:
2017-01-17 16:40:36.939 — SSH INFO: kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
2017-01-17 16:40:36.942 — SSH INFO: kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
2017-01-17 16:40:36.944 — SSH INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
2017-01-17 16:40:36.946 — SSH INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
2017-01-17 16:40:36.947 — SSH INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
2017-01-17 16:40:36.949 — SSH INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
2017-01-17 16:40:36.950 — SSH INFO: kex: client: none
2017-01-17 16:40:36.951 — SSH INFO: kex: client: none
2017-01-17 16:40:36.952 — SSH INFO: kex: client:
2017-01-17 16:40:36.953 — SSH INFO: kex: client:
2017-01-17 16:40:36.953 — SSH INFO: kex: server->client aes128-ctr hmac-md5 none
2017-01-17 16:40:36.955 — SSH INFO: kex: client->server aes128-ctr hmac-md5 none
2017-01-17 16:40:36.960 — SSH INFO: SSH_MSG_KEX_ECDH_INIT sent
2017-01-17 16:40:36.961 — SSH INFO: expecting SSH_MSG_KEX_ECDH_REPLY
2017-01-17 16:40:36.970 — SSH INFO: ssh_rsa_verify: signature true
2017-01-17 16:40:36.973 — SSH WARN: Permanently added ‘dev.server.local’ (RSA) to the list of known hosts.
2017-01-17 16:40:36.975 — SSH INFO: SSH_MSG_NEWKEYS sent
2017-01-17 16:40:36.976 — SSH INFO: SSH_MSG_NEWKEYS received
2017-01-17 16:40:36.979 — SSH INFO: SSH_MSG_SERVICE_REQUEST sent
2017-01-17 16:40:36.980 — SSH INFO: SSH_MSG_SERVICE_ACCEPT received
2017-01-17 16:40:36.987 — SSH INFO: Authentications that can continue: publickey
2017-01-17 16:40:36.989 — SSH INFO: Next authentication method: publickey
2017-01-17 16:40:37.280 — SSH INFO: Authentication succeeded (publickey).
2017-01-17 16:40:37.543 — Connection failed (postgres-jdbc-15996e6e5d1-88ac6223155bb8dc)
2017-01-17 16:40:37.546 — SSH INFO: Disconnecting from dev.server.local port 22
2017-01-17 16:40:37.548 — SSH INFO: Caught an exception, leaving main loop due to Socket closed
2017-01-17 16:40:37.560 — org.jkiss.dbeaver.model.exec.DBCConnectException: La tentative de connexion a échoué.
org.jkiss.dbeaver.model.exec.DBCConnectException: La tentative de connexion a échoué.
at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.openConnection(JDBCDataSource.java:173)
at org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource.openConnection(PostgreDataSource.java:352)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext.connect(JDBCExecutionContext.java:73)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.(JDBCDataSource.java:99)
at org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource.(PostgreDataSource.java:77)
at org.jkiss.dbeaver.ext.postgresql.PostgreDataSourceProvider.openDataSource(PostgreDataSourceProvider.java:97)
at org.jkiss.dbeaver.registry.DataSourceDescriptor.connect(DataSourceDescriptor.java:702)
at org.jkiss.dbeaver.runtime.jobs.ConnectJob.run(ConnectJob.java:74)
at org.jkiss.dbeaver.ui.dialogs.connection.ConnectionWizard$ConnectionTester.run(ConnectionWizard.java:222)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:103)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: org.postgresql.util.PSQLException: La tentative de connexion a échoué.
at org.postgresql.Driver$ConnectThread.getResult(Driver.java:355)
at org.postgresql.Driver.connect(Driver.java:279)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.openConnection(JDBCDataSource.java:159)
… 10 more
Caused by: java.io.EOFException
at org.postgresql.core.PGStream.receiveChar(PGStream.java:282)
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:421)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:217)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
at org.postgresql.jdbc.PgConnection.(PgConnection.java:215)
at org.postgresql.Driver.makeConnection(Driver.java:404)
at org.postgresql.Driver.access$100(Driver.java:52)
at org.postgresql.Driver$ConnectThread.run(Driver.java:314)
at java.lang.Thread.run(Unknown Source)
2017-01-17 16:41:39.686 — Shutdown Core…
2017-01-17 16:41:39.911 — Shutdown completed in 225ms

The error is not very clear, thanks for your help.

The java.io.EOFException is a checked exception in Java that occurs when an end of file or end of stream is reached unexpectedly during input. This exception is mainly used by data input streams to signal end of stream.

Since EOFException is a checked exception, it must be explicitly handled in methods that can throw this exception — either by using a try-catch block or by throwing it using the throws clause.

What Causes EOFException

While reading the contents of a file or stream using DataInputStream objects, if the end of the file or stream is reached unexpectedly, an EOFException is thrown. Methods of the DataInputStream class that are used to read data such as readBoolean(), readByte() and readChar() can throw this exception.

Many other input operations return a special value on end of file or stream rather than throwing an exception.

EOFException Example

Here’s an example of a EOFException thrown when trying to read all characters from an input file:

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class EOFExceptionExample {
    public static void main(String[] args) {
        DataInputStream inputStream = null;

        try {
            inputStream = new DataInputStream(new FileInputStream("myfile.txt"));

            while (true) {
                inputStream.readChar();
            }
        } catch (IOException ioe) {
            ioe.printStackTrace();
        } finally {
            try {
                inputStream.close();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }
    }
}

In the above example, the contents of a file with the name myfile.txt are read in an infinite loop using the DataInputStream.readChar() method. When the readChar() method is called at the end of the file, an EOFException is thrown:

java.io.EOFException
    at java.base/java.io.DataInputStream.readChar(DataInputStream.java:369)
    at EOFExceptionExample.main(EOFExceptionExample.java:13)

How to Fix EOFException

Since EOFException is a checked exception, a try-catch block should be used to handle it. The try block should contain the lines of code that can throw the exception and the catch block should catch and handle the exception appropriately.

The above example can be updated to handle the EOFException in a try-catch block:

import java.io.DataInputStream;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.IOException;

public class EOFExceptionExample {
    public static void main(String[] args) {
        DataInputStream inputStream = null;

        try {
            inputStream = new DataInputStream(new FileInputStream("myfile.txt"));

            while (true) {
                try {
                    inputStream.readChar();
                } catch (EOFException eofe) {
                    System.out.println("End of file reached");
                    break;
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                }
            }
        } catch (IOException ioe) {
            ioe.printStackTrace();
        } finally {
            try {
                inputStream.close();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }
    }
}

Here, the inputStream.readChar() method call is placed in a try block and the EOFException is caught inside the catch block. When an EOFException occurs at the end of the file, it is handled and a break statement is used to break out of the loop.

Track, Analyze and Manage Errors With Rollbar

Managing errors and exceptions in your code is challenging. It can make deploying production code an unnerving experience. Being able to track, analyze, and manage errors in real-time can help you to proceed with more confidence. Rollbar automates error monitoring and triaging, making fixing Java errors easier than ever. Sign Up Today!

Плагин Eclipse Hadoop сообщает «java.io.EOFException» при попытке подключения

  • Я пытаюсь настроить Eclipse для Hadoop, используя этот страница
  • Я использую банку плагина hadoop eclipse из здесь
  • мой core-site.xml выглядит следующим образом:
  <property>
  <name>fs.default.name</name>
  <value>hdfs://localhost:54310</value>
  <description>The name of the default file system.  A URI whose
  scheme and authority determine the FileSystem implementation.  The
  uri's scheme determines the config property (fs.SCHEME.impl) naming
  the FileSystem implementation class.  The uri's authority is used to
  determine the host, port, etc. for a filesystem.</description>
</property>
</configuration>
  • у моего mapred-site.xml есть следующие
<property>
  <name>mapred.job.tracker</name>
  <value>localhost:54311</value>
  <description>The host and port that the MapReduce job tracker runs
  at.  If "local", then jobs are run in-process as a single map
  and reduce task.
  </description>
</property>
  • Я настроил расположение hadoop в перспективе mapreduce в Eclipse как

    Название локации: местная карта Reduce Master

    • Хост: localhost
    • порт: 54310

    Мастер DFS

    • Хост: localhost
    • порт: 54311
  • Когда я пытаюсь подключиться, появляется сообщение об ошибке:

Ошибка: вызов localhost / 127.0.0.1: 54311 завершился неудачно при локальном исключении: java.io.EOFException

  • Может ли кто-нибудь помочь мне решить эту проблему?

спасибо

3 ответы

У меня не было особых проблем. Гугл даст вам https://issues.apache.org/jira/browse/MAPREDUCE-1280
Используйте файл jar в своем затмении

$ cat mapred-site.xml 

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!-- Put site-specific property overrides in this file. -->

<configuration>
    <property>
        <name>mapred.job.tracker</name>
        <value>localhost:8021</value>
    </property>
</configuration>

Я установил мастер на 8021 и мастер DFS на 8020.

Я думаю, вы делаете ту же ошибку, что и я. Поменяйте местами номера портов в конфигурации eclipse, и он должен работать.

Создан 27 июля ’18, 04:07

К сожалению, плагин eclipse устарел, несколько месяцев назад мне удалось заставить его работать нормально, но это был кошмар, мне пришлось изменить там множество параметров: (

Я бы порекомендовал использовать веб-просмотр hdfs: перейдите в http://localhost:50070 или любой другой хост, на котором вы установили hadoop, и нажмите ссылку «Обзор файловой системы» (первая синяя ссылка сверху), вы увидите все, что вам нужно.

Создан 05 фев.

Я не думаю, что это проблема конфигурации HADOoop. Возможно, это было вызвано плагином hadoop eclipse.

Когда вы создаете проект hadoop, который не относится к типу Map / Reduce Project (тип проекта предоставлен плагином). Когда вы тестируете код MapReduce в этом проекте с помощью плагина hadoop eclipse, он генерирует исключение EOFException.

Тот же код и та же конфигурация hadoop успешно работает в проекте Map / Reduce.

ответ дан 20 авг.

Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками

java
eclipse
apache
ubuntu
hadoop

or задайте свой вопрос.

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • 07e8 код ошибки kia
  • 07e8 код ошибки bmw