Andrus Adamchik <andru..bjectstyle.org> wrote:
> IIRC my earlier tests with Oracle showed that reconnect worked on certain
> errors, but not all
> (http://objectstyle.org/cayenne/faq/deploy.html#reconnect). I guess better
> reconnect support may require wrapping more of JDBC classes with custom
> implementations (not only the Connection).
At the bottom is the "Closed Connection" error I've managed to recreate.
At least one place the error happens is at the
"connectionObj.setAutoCommit(true);" in the following code.
Is there anything I can do to handle this better?
Can I catch an SQLException by wrapping the current try, and issue a
reconnect() at this point?
-Mike
public Connection getConnection() throws SQLException {
if (connectionObj == null) {
reconnect();
}
// set autocommit to false to return connection
// always in consistent state
if (!connectionObj.getAutoCommit()) {
try {
connectionObj.setAutoCommit(true);
} catch (SQLException sqlEx) {
// try applying Sybase patch
ConnectionWrapper.sybaseAutoCommitPatch(
connectionObj,
sqlEx,
true);
}
}
connectionObj.clearWarnings();
return new ConnectionWrapper(connectionObj, this);
}
Cayenne INFO [Thread-5 07-07 13:41:24] QueryLogger: *** error.
java.sql.SQLException: Closed Connection
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:158)
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:305)
at
oracle.jdbc.driver.PhysicalConnection.setAutoCommit(PhysicalConnection.java:1077)
at
org.objectstyle.cayenne.conn.PooledConnectionImpl.getConnection(PooledConnectionImpl.java:171)
at
org.objectstyle.cayenne.conn.PoolManager.getConnection(PoolManager.java:434)
at
org.objectstyle.cayenne.conn.PoolManager.getConnection(PoolManager.java:385)
at
org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:295)
at
org.objectstyle.cayenne.access.DataDomain.performQueries(DataDomain.java:662)
at
org.objectstyle.cayenne.access.DataContext.performQueries(DataContext.java:1359)
at
org.objectstyle.cayenne.access.Transaction.performQueries(Transaction.java:176)
at
org.objectstyle.cayenne.access.DataContext.performQueries(DataContext.java:1282)
at
org.objectstyle.cayenne.access.DataContext.performQuery(DataContext.java:1248)
at
com.gvea.cayenne.GenericEntity.objectsLikeIgnoreCaseKeyAndValue(GenericEntity.java:230)
This archive was generated by hypermail 2.0.0 : Wed Jul 07 2004 - 17:56:15 EDT