wood burning stoves 2.0*
The moose likes JDBC and the fly likes JDBC and JRE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC and JRE" Watch "JDBC and JRE" New topic
Author

JDBC and JRE

Senthamizh
Greenhorn

Joined: Jun 17, 2002
Posts: 18
1) When we load the JDBC Drivers, what is happening in JRE of both client and the Server?
2) What is the Difference between loading the drivers using Class.forName() and Driver.registerDriver() methods?
3) Why do we need Type-1 to Type-4?. Why dont we use single Driver for ALL?.
4) Difference between 'Statement', PreparedStatemet and CallableStatement?
Kevin Mukhar
Ranch Hand

Joined: Nov 28, 2000
Posts: 83
Originally posted by Senthamizh Selvan:
1) When we load the JDBC Drivers, what is happening in JRE of both client and the Server?

Nothing on the server. In the client, the driver classes are loaded from the classpath.

2) What is the Difference between loading the drivers using Class.forName() and Driver.registerDriver() methods?

Calling registerDriver() causes the driver class to be registered twice. This is because the driver class is required by the JDBC spec to register itself. Then registerDriver() registers the class again. Class.forName() is the preferred way to explicitly load and register the driver. This is not the only way to load the drivers.

3) Why do we need Type-1 to Type-4?. Why dont we use single Driver for ALL?.

Why don't we all use the same programming language? There are different solutions for different requirements. Type 1 is used when you have an ODBC driver but no JDBC driver other than Type 1. Type 2 is considered to be fast (this may or may not be true for your driver) because it uses native code, but it is also platform specific. Type 4 is pure Java so it can be used with any platform that has a JVM or JRE. Type 3 is used when you must access the database through another server layer.

4) Difference between 'Statement', PreparedStatemet and CallableStatement?[/QB]

Statement - used for most SQL commands
PreparedStatement - used for SQL commands that are frequently reused with different data values
CallableStatemenet - used to call stored procedures.
Most of these questions are probably answered at the Java JDBC tutorial at http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html or the Getting Started Guide at http://java.sun.com/j2se/1.4/docs/guide/jdbc/getstart/GettingStartedTOC.fm.html
 
jQuery in Action, 2nd edition
 
subject: JDBC and JRE
 
Similar Threads
Difference between Type II and Type IV driver
Example drivers for all the 4 types of JDBC Drivers
How we know which JDBC version we are using
about Jbdc driver
Oracle Drivers