This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
To the parameter of Class.forName, we give give name of abc.class file, as 'abc'. As i know with that, it returns object associated with it. Instead of it, why dont we simply get its object by new abc()? As i know is, with Class.forName , you register that driver . Is it true ? or there are more secrets to this concept ? from, vikram.
From the Sun JDC: http://developer.java.sun.com/developer/qow/archive/114/index.html The purpose of the JDBC API is to make it easy to use other drivers. For example, the driver can be passed into a application using a command line system property. The pseudo code for this could look like this: String driver = System.getProperties().getProperties("db.driver"); Class.forName(driver); The application runs like this: java -Ddb.driver=abc.def.SybDriver MyApp Alternatively, you do not need to load a driver dynamically. You can load it like any other class: import abc.def.MyDriver; MyDriver myDriver = new MyDriver();
Hi, In a JDBC program, one of the first things to do is to load the JDBC driver by calling the forName() static method of the Class class. forName() takes one string parameter: the name of the driver along with its package. For JavaSoft's JDBC-ODBC Bridge, this string is "sun.jdbc.odbc.JdbcOdbcDriver". Therefore, the call would look like: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");