简体   繁体   中英

Creation of new database connection in java using oracle jdbc template

/* connection pool created with 5 connections based on the region specific.
 with below code it will get connection from connection pool which is already created.*/

Connection con = DatasourceClient.getDataSourceMap.get(region).getConnection();
OracleConnection oConn = con.unwrap(oracle.jdbc.OracleConnection.class);

Will above code will get two connections from pool and do i need to close both con and Oconn?

i am getting pool exhausted and connection closed exceptions tried many ways by changing pool properties. So just want to know what above code is doing.

tried closing the above connections but didn't get any difference results.

Using Oracle Jdbc template instead of spring jdbc because in my procedures there are array values which in few cases only input, in some cases only output and other both INOUT.

Can any one help me in this please? Thank you.

No, it will get only a single connection out, which you then unwrap to it's actual class.

However you will need to call con.close() (and never oCon.close() ) to return the connection back to the pool. This is because the wrapper's close() doesn't actually close the connection, it returns it back to the pool.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM