Win a copy of Microservices in Action this week in the Web Services forum!
  • 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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: 21466
97
Chrome Eclipse IDE Java Spring Ubuntu VI Editor 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!