Skip to main content

What is "Wrap JDBC Objects"

8 replies [Last post]
cvoronin
Offline
Joined: 2007-03-13

In the Advanced tab of Connection pool properties there is "Wrap JDBC Objects" option.

The decription of that property is: "When set to true, application will get wrapped jdbc objects for Statement, PreparedStatement, CallableStatement, ResultSet, DatabaseMetaData"

I really don't understand - what means "wrapped jdbc objects" in this context. What is the wrapper for these objects? Is it a connection? What does the wrapper do?

Thank you!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
eskatos
Offline
Joined: 2007-05-14

Could it be possible that this leads to blocked threads when using XADataSources ?

jr158900
Offline
Joined: 2005-04-13

on first thought, no.
But I would like to understand more about your issue.

jr158900
Offline
Joined: 2005-04-13

According to JDBC Spec, DataSource.getConnection() and obtaining connection via other objects like statement, preparedStatement.getConnection() should be same.

GlassFish always wraps connection by design, but does not wrap others like statement, preparedStatement. Because of this, statement.getConnection() will return the physical connection rather than the one provided by GlassFish.

wrap-jdbc-objects=true will make sure that statement.getConnection will be the same as DataSource.getConnection()

davideagen
Offline
Joined: 2005-08-15

Can someone explain why this might be valuable? Would it prevent an improperly written application from mucking up the pool or something like that?

-Dave

jr158900
Offline
Joined: 2005-04-13

If an application calls statement.getConnection() underlying physical connection will be returned. Application may call connection.close() which will result in closing the physical connection. This will affect the pooling infrastructure of appserver.

davideagen
Offline
Joined: 2005-08-15

Ah I see.

Is there a way to set this value when creating a pool via asadmin commands?

jr158900
Offline
Joined: 2005-04-13

Yes, you can use "dotted-names-set"

eg :

asadmin list "*DerbyPool*"
domain.resources.jdbc-connection-pool.DerbyPool
server.resources.jdbc-connection-pool.DerbyPool

asadmin get domain.resources.jdbc-connection-pool.DerbyPool.*
...
...
domain.resources.jdbc-connection-pool.DerbyPool.validate-atmost-once-period-in-seconds = 0
...
domain.resources.jdbc-connection-pool.DerbyPool.wrap-jdbc-objects = false

asadmin set domain.resources.jdbc-connection-pool.DerbyPool.wrap-jdbc-objects=true
domain.resources.jdbc-connection-pool.DerbyPool.wrap-jdbc-objects = true

davideagen
Offline
Joined: 2005-08-15

Thanks, I wasn't aware of that method of setting properties.

-Dave