[Logo]
Forums Register Login
Doubt regarding java database connectivity.
Hi everybody, I am Chaitanya, I have a doubt regarding JDBC.

What I know till few days back was whenever a user sends a request and if it is associated with some database related query we open a database connection and get the thing done. Assuming that I am not using any connection pool. So for each request a connection opens. So for 100 requests 100 connections will open. This is what I know.

Actually DriverManager.getConnection(String,String,String) is static method, implemented in singleton pattern. So irrespective of number of requests there will be only one connection object.

Am I right? Can anyone tell me? Thank you all in advance. Have a good day.
 

DriverManager.getConnection(String,String,String) is static method, implemented in singleton pattern



How will you verify that statement. I would see the source of that method...Download JDK source...
@Sunny: follow link
 

chaitanya karthikk wrote:Actually DriverManager.getConnection(String,String,String) is static method, implemented in singleton pattern. So irrespective of number of requests there will be only one connection object.

Am I right? Can anyone tell me?


You're wrong. A static method doesn't automatically mean the singleton pattern is used. The DriverManager.getConnection methods are factory methods, creating new connections each time (since no connection pooling is used).
Thanks Mr. Rob.

This thread has been viewed 1078 times.

All times above are in ranch (not your local) time.
The current ranch time is
Nov 17, 2018 12:17:38.