• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

connection

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Through a simple java application when we want a connection we often do as-
new sun.jdbc.odbc.JdbcOdbcDriver();
what it exactly does mean?
creating Driver's instance if yes then where is the instance variable here?
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the instance of sun.jdbc.odbc.JdbcOdbcDriver is created, this JdbcOdbcDriver has static method where it creates a instance of this driver and gets registered to the DriverManger class. The instance of the driver is holded by DriverManager class.

The Code of sun.jdbc.odbc.JdbcOdbcDriver:
static
{
JdbcOdbcTracer jdbcodbctracer = new JdbcOdbcTracer();
if(jdbcodbctracer.isTracing())
jdbcodbctracer.trace("JdbcOdbcDriver class loaded");
JdbcOdbcDriver jdbcodbcdriver = new JdbcOdbcDriver();
try
{
DriverManager.registerDriver(jdbcodbcdriver);
}
catch(SQLException sqlexception)
{
if(jdbcodbctracer.isTracing())
jdbcodbctracer.trace("Unable to register driver");
}
}

That's the reason we will say DriverManager.getConnection().
 
This will take every ounce of my mental strength! All for a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic