• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt regarding java database connectivity.

 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sunny Bhandari
Ranch Hand
Posts: 448
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Sunny: follow link
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mr. Rob.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic