Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Doubt regarding java database connectivity.  RSS feed

 
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.
 
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
 
Sheriff
Posts: 21421
94
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
Boost this thread!