Class.forName("interbase.interclient.Driver");
The first time the Java interpreter sees a reference to interbase.interclient.Driver, it loads the InterClient driver. When the driver is loaded it automatically creates an instance of itself, but there is no handle for it that lets you access that driver directly by name. This driver is "anonymous"; you don't need to reference it explicitly to make a database connection. You can make a database connection simply by using the java.sql.DriverManager class.
It's the responsibility of each newly loaded driver to register itself with the DriverManager; the programmer is not required to register the driver explicitly. After the driver is registered, the DriverManager can use it to make database connections.
java.sql.Driver driver = new interbase.interclient.Driver();Now you can reference the driver classes and methods with "driver.XXX()." If all you need to do is connect to the database and execute SQL statements, you don't need to create a driver object explicitly; the DriverManager handles everything for you. However, there are a few cases when you need to reference the driver by name. These include:
java.sql.Driver driver = new XXX.Driver
//create the InterClient driver object as a JDBC driver java.sql.Driver driver = new interbase.interclient.Driver (); //get the connection object java.sql.Connection connection = driver.connect (dbURL, properties); //reference driver to get the driver version number java.sql.String version = driver.getMajorVersion () + driver.getMinorVersion (); System.out.print ("You're using driver", + version");
interbase.interclient.Driver d = new interbase.interclient.Driver (); interbase.interclient.Connection c = d.connect (dbURL, properties);This creates an InterClient specific connection instance rather than a generic java.sql.Connection instance. Declaring your InterClient objects as java.sql interface instances allows for more database independence and code portability. If you choose to use an InterClient extension method on such an object, an explicit cast is required. This has the added bonus of tagging non-portable code fragments.