This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
phooton misra wrote:Some Body please suggest me What is the purpose of
A quick search would provide you some basic information about forName method.
Basically, Class.forName simply loads the mentioned class in JVM. This is just like an import statement, but provide more facilities (e.g. you can load a class based on some condition, or you can take name of the class from environment variable or property file etc.)
It makes Java load the class sun.jdbc.odbc.JdbcOdbcDriver.
In the case of JDBC drivers, this will make the driver class register itself so that the JDBC API knows where to find the driver when you open a database connection. Note that for newer JDBC drivers, this line isn't necessary anymore - JDBC now uses another mechanism to automatically find drivers.
See also the API documentation of the forName() method in class java.lang.Class.