I was under the impression that a JDBC connection that is returned from the connection method on the Session oject is a standalone JDBC connection.
For example:
Code:
try{
Connection c = HibernateSession.currentSession().connection();
// do the work with a prepared stmnt.
// get a resultset
// set the data in the resultset to a local variabe and return it to the client
}catch( Exception ) { // do something
}finally{
// close the connection
}
as compared to:
Code:
Context initContext = new InitialContext();
DataSource ds = (DataSource) initContext.lookup (Constants.JNDI_JDBC_KEY);
con = ds.getConnection();
// do the same work as above
// close everything the same way
Here is the problem when i use straight JDBC i can get the data and all is well as i would expect but when i use the connection returned from the Session it gets the data from the DB (i can see this from debug output at the bottom of the method) but as soon as the mehod returns, i get the exception:
Quote:
java.sql.SQLException: Connection is closed.
why is this? i set the results to a local var then return it to the caller. the implementation is exact except where i get the JDBC connection from.
Please folks what is happening here?