This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Doubt regarding java database connectivity. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Doubt regarding java database connectivity." Watch "Doubt regarding java database connectivity." New topic
Author

Doubt regarding java database connectivity.

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

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.


Love all, trust a few, do wrong to none.
Sunny Bhandari
Ranch Hand

Joined: Dec 06, 2010
Posts: 448

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...


Java Experience
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

@Sunny: follow link
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

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).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

Thanks Mr. Rob.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt regarding java database connectivity.
 
Similar Threads
Doubt in Assignment Architecture !
doubt regarding connection pooling
doubt??
Doubt in JavaServerPages and in JavaBeans???
?: doubt