JDBC and JRE

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?

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.