Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

keep connection alive

843854May 6 2004 — edited May 6 2004
I have heard from my friend who is a php programmer that they can keep their connection to the database alive in a static var such that everytime they query to the database doesn't have to open a new connection again.

I don't see any examples or anyone is doing that in java, and I really curious about the reasons behind it.
I know we could also do this in java by putting creating a static Connection instance in the class, but there are also synchronize issue. If you set the connection to be some isolation transaction such as read committed, read uncommited or auto commit to false, it may effects the whole server because everyone is using this same connection variables.

This is the only reason I see why we should use only one connection for everything. Is there anymore critical reason behind it? Such as performance issue or race condition? I really hope I can heard more different opinion on this matter.

Best regards,
michael

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2004
Added on May 6 2004
1 comment
215 views