Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is the DriverManager thread safe?

drivermanager safe thread
0
Posted

Is the DriverManager thread safe?

0

DriverManager.getConnection is a Synchronized method but it has a possiblity of deadlock, So in the feature version of JDBC the getconnection synchronization will be remove.

http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=4320da112ff752236970ea82a4577?bug_id=4263113

 

0

Yes, the DriverManager getConnection() method is thread safe. However, it is not very efficient for multiple threads to request their own connections from the driver manager, so it is recommended you use a connection pool in a production environment. A connection pool will acquire database connections on behalf of an application; when one thread has finished with a connection it is returned to the pool for re-use and this minimises the new connection time overhead. The Apache Commons Database Connection Pool (DBCP) library is a robust open source implementation of a connection pool that is widely used. A little extra effort is required to set up, but this will pay off in more rapid database connectivity. Actions: Follow-up, clarify or correct this answer. Submit a new question.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123