This content has been marked as final.
Show 2 replies
-
1. Re: Unwrapping datasource connection prevents release?
jaikiran Jun 22, 2016 3:52 AM (in response to nickarls)Since the pooling logic and keeping track of which connection is in use etc... happens within the wrapped proxy connection that you get from the datasource, I can see why all that logic would be skipped if you use the underlying connection for direct connection management. I would instead suggest changing that code to:
@Test public void testRelease() throws SQLException { OracleConnection c = null; OracleCallableStatement s = null; final Connection wrappedConnection = dataSource.getConnection(); try { c = wrappedConnection.unwrap(OracleConnection.class); s = (OracleCallableStatement) c.prepareCall("{ ? = pak.func(?) }"); s.registerOutParameter(1, Types.INTEGER); s.registerOutParameter(2, Types.VARCHAR); System.out.println(s.execute()); } catch (SQLException e) { e.printStackTrace(); } finally { if (s != null) { try { s.close(); } catch (Exception ignore) {// ignore or log} } // close the original wrapped connection wrappedConnection.close(); } }
-
2. Re: Unwrapping datasource connection prevents release?
nickarls Jun 22, 2016 3:58 AM (in response to jaikiran)Heh, I was just about to update the post with the information that unwrapping *after* the getting works ;-)