Wrap JDBC Objects - I
18 September 2008In glassfish connection pool has a property called “Wrap JDBC Objects” which can have value true or false. You may define it in domain.xml file.
This property is defined as: “When set to true, application will get wrapped jdbc objects for Statement, PreparedStatement, CallableStatement, ResultSet, DatabaseMetaData”.
If you follow JDBC specifications, you will be see that obtaining connection using DataSource.getConnection() or other objects like statement, preparedStatement.getConnection() should be same. Do note its not the same if you use Glasshfish application server. GlassFish does not wrap others like statement, preparedStatement. Because of this, statement.getConnection() will return the physical connection rather than the one provided by GlassFish. This means that you might be using physical connection rather than connection from connection pool.
For example:
stat = rs.getStatement(); con = stat.getConnection();[/b] rs.close(); rs=null; stat.close() ; stat = null; con.setAutoCommit(true); con.close();
In the above example, you close the physical connection and not the logical connection, therefore connections are not returned to pool.
continued …
Related Posts:
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Wrap JDBC Objects - I