Types of Drivers

Hello Every body,

I am interested to know about the internal happenings of Java database connectivity. Right from start to end and also please clarify me on the following questions.

1. what happens when a database connection is created and closed?

2. What resources on the database side will be used if do not close the connection? Is it a serious problem?

3. Is it adviseable to open a connection for each request in web application? If not please let me know which technique to use.

Cheers,

Divakar

[543 byte] By [bdsaia] at [2007-10-2 7:54:26]
# 1
Please post only once; answered in other thread.
StuDerbya at 2007-7-16 21:43:32 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

hi diwakar

when u r registering ur jdbc driver internally it calls a static method on DriverManager.

// for all the ways of registreing driver class

static registerDriver("Driver Class").

then when u r creating connection it calls a static synchronized method on DriverManager instance

as DriverManager.getConnection(String ,String,String);

hence it is a static synchronized method it is not gud to create connection oftenly.

if u r necessary to have the connection object for a long time then keep that alive.

if u r using the connection object rarely so create it when u r required it.

when u r calling getConnaction method it consumes valuable system time.

it has to get the DriverManager instance(It is a factory class it consumes a constuctor call of Singleton and a method call to get that instance).

Connection,Statement,ResultSet objects resources r valuable.After ur utilization u have to close that resources.

When u want to use new resources u may get the old resources if u have not closed the previous ones.

Did i answered ur question correctly.

Thanks

yugi

yugireddya at 2007-7-16 21:43:32 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

hi diwakar

when u r registering ur jdbc driver internally it calls a static method on DriverManager.

// for all the ways of registreing driver class

static registerDriver("Driver Class").

then when u r creating connection it calls a static synchronized method on DriverManager instance

as DriverManager.getConnection(String ,String,String);

hence it is a static synchronized method it is not gud to create connection oftenly.

if u r necessary to have the connection object for a long time then keep that alive.

if u r using the connection object rarely so create it when u r required it.

when u r calling getConnaction method it consumes valuable system time.

it has to get the DriverManager instance(It is a factory class it consumes a constuctor call of Singleton and a method call to get that instance).

Connection,Statement,ResultSet objects resources r valuable.After ur utilization u have to close that resources.

When u want to use new resources u may get the old resources if u have not closed the previous ones.

Did i answer ur question correctly.

Thanks

yugi

yugireddya at 2007-7-16 21:43:32 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...