cancel
Showing results for 
Search instead for 
Did you mean: 

JDBCConnectionException: Cannot open connection

Former Member
0 Kudos

Hi,

we face problems with out database connection. We are using WebAS 7.0 (java stack only) with Oracle 10g + Hibernate.

We have sized the connection pool and number of threads etc. according to the SAP recommentation.

Now, if have one or two transactions at a time everything works fine. But with several connections at a time we run into problems with the database connection. There should not be that many connections open, i.e. the transactions do not run forever.

this is our exception stack trace. Maybe someone faced a similar problem and has an idea how to solve it ?

Caused by: org.hibernate.exception.JDBCConnectionException: Cannot open connection

at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)

at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)

at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:420)

at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)

at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)

at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538)

at org.hibernate.loader.Loader.doQuery(Loader.java:661)

at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)

at org.hibernate.loader.Loader.doList(Loader.java:2211)

at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)

at org.hibernate.loader.Loader.list(Loader.java:2090)

at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:95)

at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)

at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)

at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305)

... 14 more

Caused by: com.sap.engine.services.dbpool.exceptions.BaseSQLException: ResourceException in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.dbpool.exceptions.BaseResourceException: SQLException thrown by the physical connection: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection

at com.sap.engine.services.dbpool.cci.ConnectionFactoryImpl.getConnection(ConnectionFactoryImpl.java:59)

at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69)

at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)

... 30 more

Caused by: com.sap.engine.services.dbpool.exceptions.BaseResourceException: SQLException thrown by the physical connection: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection

at com.sap.engine.services.dbpool.spi.XAManagedConnectionFactoryImpl.createManagedConnection(XAManagedConnectionFactoryImpl.java:196)

at com.sap.engine.services.connector.jca.ConnectionHashSet.match(ConnectionHashSet.java:320)

at com.sap.engine.services.connector.jca.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:234)

at com.sap.engine.services.dbpool.cci.ConnectionFactoryImpl.getConnection(ConnectionFactoryImpl.java:51)

... 32 more

Caused by: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)

at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:420)

at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)

at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)

at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)

at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:297)

at oracle.jdbc.xa.client.OracleXADataSource.getPooledConnection(OracleXADataSource.java:472)

at oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:159)

at oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:107)

at com.sap.engine.services.dbpool.spi.XAManagedConnectionFactoryImpl.createManagedConnection(XAManagedConnectionFactoryImpl.java:156)

... 35 more

Thanx for any help in advance.

Regards,

Astrid

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I suspect there could be two possible reasons:

1. Network unavailable. Can you check with one or two transactions repeteadily works fine for 15-20 minutes without breaking connection. Alternatively can check while connecting from TOAD or sqlplus whether network resets or timeouts.

2.Please check the number of connections allowed by the given user to concurrently.

Regards,

Nitin

Former Member
0 Kudos

Hi Astrid,

please check the Nitin suggestions and check if you close the various connections everytime in your code, for example if you open connections in loop structures without closing them.

Hoper this help.

Vito