1
我有一個使用Hibernate 3,c3p0和spring 2.5.6的應用程序。我們有一個配置爲與postgres數據庫交談的數據源。在應用程序服務器和數據庫之間引入防火牆之前,一切都很好。我們間歇性地獲取java.net.SocketTimeoutException:在嘗試與數據庫通信時讀取超時錯誤。如何配置c3p0/hibernate的查詢超時閾值
我們認爲防火牆的開銷會導致數據庫延遲響應。我們希望通過提高查詢超時之前的等待時間(如果甚至可能的話)的閾值來驗證這一點。這裏是一個stacktrace片段
org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:218)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1808)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1881)
... 35 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
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:1166)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192)
... 44 more
啊......我們正在運行8.2。是否有另一種操縱價值的方法? – predhme
此設置在8.3和之前不存在。請注意,我指的是JDBC版本,而不是Postgresql版本。 JDBC是向後兼容的(絕對是所有的8.x版本),所以我建議你升級你的驅動程序。 – ChssPly76
甜!沒有意識到這一點。非常感謝! – predhme