Java SQL 错误:0,SQLState:08006
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21925083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQL Error: 0, SQLState: 08006
提问by user3027299
I have a web application with hibernate connection. application is connecting to PostgreSQL db. Some times I am getting below exceptions in my logs.
我有一个带有休眠连接的 Web 应用程序。应用程序正在连接到 PostgreSQL 数据库。有时,我的日志中会出现低于异常的情况。
Caused by: **org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.**
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:252)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
at org.geotools.jdbc.JDBCFeatureReader.<init>(JDBCFeatureReader.java:150)
at org.geotools.jdbc.JDBCFeatureSource.getReaderInternal(JDBCFeatureSource.java:567)
... 101 more
**Caused by: java.io.EOFException**
at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:261)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1620)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
Caused by: org.postgresql.util.PSQLException: **An I/O error occured while sending to the backend.**
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:252)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
at org.geotools.jdbc.JDBCFeatureReader.<init>(JDBCFeatureReader.java:150)
at org.geotools.jdbc.JDBCFeatureSource.getReaderInternal(JDBCFeatureSource.java:567)
... 101 more
**Caused by: java.net.SocketException: Connection reset**
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:135)
at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:104)
at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:259)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1620)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
What might be the problem. Is there anything i need to change it in my hibernate configuration files or any code issues. Please give me your suggestions?
可能是什么问题。我需要在我的休眠配置文件或任何代码问题中更改它。请给我你的建议?
find the below my hibernate configuration
在下面找到我的休眠配置
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
please find the below my postgreSQL logs
请在下面找到我的 postgreSQL 日志
2014-02-19 07:22:35 IST LOG: server process (PID 74813) was terminated by signal 6: Aborted
2014-02-19 07:22:35 IST LOG: terminating any other active server processes
2014-02-19 07:22:35 IST WARNING: terminating connection because of crash of another server process
2014-02-19 07:22:35 IST DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2014-02-19 07:22:35 IST HINT: In a moment you should be able to reconnect to the database and repeat your command.
2014-02-19 07:22:35 IST WARNING: terminating connection because of crash of another server process
2014-02-19 07:22:35 IST DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2014-02-19 07:22:35 IST HINT: In a moment you should be able to reconnect to the database and repeat your command.
2014-02-19 07:22:35 IST LOG: all server processes terminated; reinitializing
2014-02-19 07:22:35 IST LOG: database system was interrupted; last known up at 2014-02-19 07:22:29 IST
2014-02-19 07:22:35 IST LOG: database system was not properly shut down; automatic recovery in progress
2014-02-19 07:22:35 IST LOG: record with zero length at 0/16D89BB0
2014-02-19 07:22:35 IST LOG: redo is not required
2014-02-19 07:22:35 IST LOG: autovacuum launcher started
2014-02-19 07:22:35 IST LOG: database system is ready to accept connections
2014-02-19 11:17:59 IST LOG: unexpected EOF on client connection
2014-02-19 11:17:59 IST LOG: unexpected EOF on client connection
2014-02-19 11:17:59 IST LOG: unexpected EOF on client connection
2014-02-19 11:17:59 IST LOG: unexpected EOF on client connection
2014-02-19 11:17:59 IST LOG: unexpected EOF on client connection
2014-02-19 11:17:59 IST LOG: unexpected EOF on client connection
2014-02-19 11:17:59 IST LOG: unexpected EOF on client connection
2014-02-19 11:17:59 IST LOG: unexpected EOF on client connection
My Server OS is - Red Hat Enterprise Linux 6 64-bitand postgreSQL version - postgreSQL 9.1
我的服务器操作系统是 - Red Hat Enterprise Linux 6 64 位和 postgreSQL 版本 - postgreSQL 9.1
采纳答案by Craig Ringer
Ok, that's interesting:
好吧,这很有趣:
2014-02-19 07:22:35 IST LOG: server process (PID 74813) was terminated by signal 6: Aborted
2014-02-19 07:22:35 IST 日志:服务器进程(PID 74813)被信号 6 终止:中止
That indicates that the PostgreSQL server backend is crashing. Specifically, signal 6 (SIGABRT) is triggered by assertion failures, places the code intentionally crashes because something is wrong and it can't continue without risking data corruption.
这表明 PostgreSQL 服务器后端正在崩溃。具体来说,信号 6 (SIGABRT) 是由断言失败触发的,由于出现问题而故意使代码崩溃,并且在不冒数据损坏的风险的情况下无法继续。
If you are not running the latest patch release of your PostgreSQL version (which you did not mention), update now.
如果您没有运行 PostgreSQL 版本的最新补丁版本(您没有提到),请立即更新。
(The rest is really more questions, but SO's format sometimes makes comments just too restrictive):
(其余的确实是更多的问题,但 SO 的格式有时会使评论过于严格):
I recommend enabling log_statement = all
with a log_line_prefix
that includes at least the backend pid and transaction ID. Then reloading PostgreSQL to make the setting active. When the problem next happens, look in the query logs to see what the crashing process was executing at the time it crashed. See if running the same statement interactively on the console causes the crash too.
我建议使log_statement = all
用log_line_prefix
,其包括至少后端PID和事务ID。然后重新加载 PostgreSQL 以激活设置。下次出现问题时,请查看查询日志以查看崩溃进程在崩溃时正在执行的操作。查看在控制台上以交互方式运行相同的语句是否也会导致崩溃。
I also recommend enabling core dump files and downloading the debuginfo packages for your PostgreSQL version. This will allow you to attach a debugger to a file that contains the state of the server when it crashed, and hopefully see what went wrong. How to enable core-dumps is OS/distro specific and you haven't mentioned your operating system and version so I can't offer more specific instructions; see Google.
我还建议启用核心转储文件并为您的 PostgreSQL 版本下载 debuginfo 包。这将允许您将调试器附加到包含服务器崩溃时的状态的文件中,并希望看到哪里出了问题。如何启用核心转储是特定于操作系统/发行版的,您没有提到您的操作系统和版本,所以我无法提供更具体的说明;见谷歌。
回答by Sai Ye Yan Naing Aye
According to postgresql documentation, you faced connection_failureproblem.So check the following steps,
根据postgresql 文档,您遇到了connection_failure问题。因此请检查以下步骤,
- Check your connection configuration into your hibernate configuration file
- Check your database connection is opened or not.
- Check your network connection
- The above are not ok please post your postgressql log file again
- 将您的连接配置检查到您的休眠配置文件中
- 检查您的数据库连接是否打开。
- 检查您的网络连接
- 以上都不行,请再次发布您的postgressql日志文件
回答by JanBrus
In my case, this error was caused by truncates i have done on tables, but did not commit the transaction. (I used DBeaver tool)
在我的例子中,这个错误是由我对表所做的截断引起的,但没有提交事务。(我使用了 DBeaver 工具)