Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connection

 
Devaki Nihar
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?
 
Gopi Kishore
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().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic