db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Synchronization on the connection in JDBC calls
Date Thu, 29 Jun 2006 12:59:01 GMT

When working on EmbedPreparedStatement.java, I noticed that a few 
methods synchronize on the connection object, for instance addBatch. The 
code typically looks like this:

synchronized (getConnectionSynchronization()) {
	// Do stuff

The getConnectionSynchronization-method returns a reference to the root 
connection. I also saw that EmbedResultSet uses this more.
The rest of the JDBC methods in EmbedPreparedStatement don't synchronize 
on this object.

I think a single connection is not expected to be shared between 
multiple threads simultaneously. Maybe the necessary synchronization is 
done at a lower level in the system.

Would anyone care to share their thoughts/knowledge on this issue?


View raw message