Reference | Help | Introduction | Slide Show | Class Hierarchy | InterClient | ||
PREV | NEXT | FRAMES | NO FRAMES |
Connections are traditionally established using an explicit database URL through the DriverManager as follows:
Class.forName ("interbase.interclient.Driver"); java.sql.Connection c = DriverManager.getConnection ("jdbc:interbase://server/c:/database-dir/atlas.gdb", "sysdba", "masterkey");Connections may also be established through a Driver instance as follows:
java.sql.Driver d = new interbase.interclient.Driver (); java.sql.Connection c = d.connect ("jdbc:interbase://server/c:/database-dir/atlas.gdb", "sysdba", "masterkey");When the Driver class is loaded, an anonymous driver instance is automatically created and registered with the driver manager. The driver manager will locate the driver instance based on the URL prefix "jdbc:interbase:".
Note: Because of a bug in the JDK 1.1.x with Class.forName(). There is a race condition in the class loader, and it is sometimes possible that the class loader is prevented from executing the static section of code in the driver class. This would prevent the loaded driver class from registering itself with the driver manager. So Class.forName () may appear to succeed with no exception thrown, but the driver may not be registered with the driver manager. One work-around is to obtain a connection from an explicitly constructed driver instance as follows:
java.sql.Driver d = new interbase.interclient.Driver (); java.sql.Connection c = d.connect ("jdbc:interbase://server/c:/database-dir/atlas.gdb", "sysdba", "masterkey");
For further details, see the InterClient examples directory for class DriverExample.java
When using the JDBC 1 DriverManager/Driver API, connection properties may also be passed to the driver when a connection is requested with
See DataSource and Connection Properties for a specification of the InterClient connection properties (InterClient 2 Only).
Using the JDBC 2 DataSource API (InterClient 2 Only)
The JDBC 2 Standard Extension introduces a DataSource facility and provides an alternative to the JDBC 1 DriverManager, essentially duplicating all of the driver manager’s useful functionality. Although, both mechanisms may be used by the same application if desired, JavaSoft encourages developers to regard the DriverManager as a legacy feature of the JDBC API. Applications should use the DataSource API whenever possible. A JDBC implementation that is accessed via the DataSource API is not automatically registered with the DriverManager. The DriverManager, Driver, and DriverPropertyInfo interfaces may be deprecated in the future.
See the API Reference for class DataSource for an example of how to register an InterClient data source object with a JNDI naming service, and an example of looking up a data source registered in with JNDI.
See DataSource and Connection Properties for a specification of the InterClient data source properties.
For example code using DataSources see DataSourceExample.java, JNDIExample.java, and ServerManagerExample.java.
Reference | Help | Introduction | Slide Show | Class Hierarchy | InterClient | ||
PREV | NEXT | FRAMES | NO FRAMES |