keep connection alive
843854May 6 2004 — edited May 6 2004I 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