views:

301

answers:

2

[Cross-Posting from ServerFault]

I am in a development environment, and our test Oracle 9i server has been misbehaving for a few days now. What happens is that we have our JDBC connections disconnecting after a few successful connections.

We got this box set up by our IT department and handed over to. It is 'our problem', so options like 'ask you DBA' isn't going to help me. :(

Our server is set up with 3 plain databases (one is the main dev db, the other is the 'experimental' dev db). We use the Oracle 10 ojdbc14.jar thin JDBC driver (because of some bug in the version 9 of the driver). We're using Hibernate to talk to the DB.

The only thing that I can see that changed is that we now have more users connecting to the server. Instead of one developer, we now have 3. With the Hibernate connection pools, I'm thinking that maybe we're hitting some limit?

Anyone has any idea what's going on?

Here's the stack trace on the client:

Caused by: org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126) [hibernate3.jar:na]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114) [hibernate3.jar:na]
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) [hibernate3.jar:na]
at org.hibernate.loader.Loader.doList(Loader.java:2235) [hibernate3.jar:na]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129) [hibernate3.jar:na]
at org.hibernate.loader.Loader.list(Loader.java:2124) [hibernate3.jar:na]
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) [hibernate3.jar:na]
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363) [hibernate3.jar:na]
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) [hibernate3.jar:na]
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149) [hibernate3.jar:na]
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) [hibernate3.jar:na]
...
Caused by: java.sql.SQLException: Io exception: Connection reset
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.4.0"]
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.4.0"]
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.4.0"]
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:829) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.4.0"]
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1049) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.4.0"]
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:854) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.4.0"]
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1154) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.4.0"]
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.4.0"]
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3415) [ojdbc14.jar:Oracle JDBC Driver version - "10.2.0.4.0"]
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) [hibernate3.jar:na]
at org.hibernate.loader.Loader.getResultSet(Loader.java:1812) [hibernate3.jar:na]
at org.hibernate.loader.Loader.doQuery(Loader.java:697) [hibernate3.jar:na]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) [hibernate3.jar:na]
at org.hibernate.loader.Loader.doList(Loader.java:2232) [hibernate3.jar:na]
A: 

Which JDK are you using for Java? ojdbc14 is intended for JDK 1.4 and earlier. There might be a bug in this version for your database, but if you're using JDK 5 or 6 I'd recommend finding a version of the JDBC driver for your JDK. The JAR name would indicate JDK 5 or 6 in some way.

A Google search turned up this thread from the Oracle forums. Take a look at the Oracle logs and see if there's a message similar to the one quoted in that thread.

duffymo
I concur. If there's no ORA- or TNS- oracle message in your stack trace, just a Connection Reset, the server process likely failed leaving a trace file on the database server in USER_DUMP_DEST. You'll have to have your DBA find the trace file for the time of the error, assuming it's still there, to help diagnose the issue.
Adam Musch
I've used the latest and brightest driver ojdbc6.jar, and the issue hasn't changed... just the stack trace has a few different exceptions types.
mlaverd
Can you reproduce this behavior with simple code?
duffymo
A: 

I had similar issue with Oracle and other databases. It happens when db server close connection (e.g. by timeout). You could easily handle the situation with connection pool (e.g. c3p0). See also here and here.

Just in case, my c3p0.properties file looks like:

c3p0.preferredTestQuery=SELECT 1 from dual
c3p0.maxConnectionAge=3600
c3p0.testConnectionOnCheckout=true
c3p0.acquireRetryDelay=1000
c3p0.acquireRetryAttempts=30
c3p0.breakAfterAcquireFailure=false
FoxyBOA