The following sections explain what you need to do to use the LDAP JDBC Driver for the first time.
A JDBC driver is a collection of Java classes that conform to the JDBC specification. For the LDAP JDBC Driver, these classes are contained in the jar file, ldapjdbc.jar. This jar file must be in the Java class path in order to use the LDAP JDBC Driver. The installation program installs the ldapjdbc.jar file on your machine in the c:\Novell\Java\lib directory unless you specify a path.
The LDAP JDBC Driver is implemented on top of the LDAP Extensions and Controls for JNDI. The LDAP Extensions and Controls for JNDI require the following jar files:
Table 1-1 Jar File Description
|
Jar File |
Description |
|---|---|
|
jndi.jar |
JNDI 1.2 (Java Naming and Directory Interface) is a Java standard extension API. This is included with JDK 1.4 |
|
ldap.jar |
LDAP (Light-weight Directory Access Protocol) provider allows JNDI to access eDirectory and other directories over LDAP. This is included with JDK 1.4. |
|
providerUtil.jar |
Provides utility functions for JNDI providers. This is included with JDK 1.4. |
|
novbp.jar |
Provides access to the eDirectory specific
features through LDAP extensions. This is available by downloading |
One of the classes in a JDBC driver is designated as the main driver class. This main driver class must be loaded by your program or by the database tool you are using. The name of the main driver class for the LDAP JDBC Driver is com.novell.sql.LDAPDriver. This class is locate in the ldapjdbc.jar file.
Database tools provide a mechanism for you to specify this class name, and then the tool loads the driver. If you are programming directly to the LDAP JDBC Driver, use the following line of code to load the driver.
Class.forName("com.novell.sql.LDAPDriver");
This line of code causes the com.novell.sqo.LDAPDriver class to be loaded. When this class is loaded, it registers itself with the JDBC DriverManager class which makes it available for use.
The JDBC protocol uses a URL for the following:
The URL is always used when programming directly to the driver using the JAVA language and is generally used by most database access tools. The URL for the LDAP JDBC Driver has the following format:
JDBC:LDAP:<ldap server>[;<property name>=<attribute name>]* [;baseDN=<base DN>]
The following table describes each part of the URL.
Table 1-2 Field Description of an LDAP URL
The JDBC driver supports the following properties.
Table 1-3 Properties Supported by the JDBC Driver
When programming in Java, a connection is created by passing the URL to the getConnection method of the DriverManager Class. Several examples are shown below. Note that there are three versions of the getConnection method.
String url = "JDBC:LDAP://137.64.215.139" +
";user=cn=jbrown,o=acme" +
";password=myPassword" +
";baseDN=ou=enginerring,o=ACME";
Connection conn = DriverManager.getConnection(url);
String url = "JDBC:LDAP://137.64.215.139" +
";baseDN=ou=enginerring,o=ACME";
Connection conn = DriverManager.getConnection(url,
"cn=jbrown,o=acme",
"myPassword");
String url = "JDBC:LDAP://ldapserver.ACME.com" +
Properties props = new Properties();
props.put("user", "cn=jbrown,o=acme");
props.put("password", "myPassword");
props.put("baseDN", "ou=engineering,o=ACME");
Connection conn = DriverManager.getConnection(url, props);
Once a connection has been established you can use the connection object to execute one or more queries.
For more information on using the JDBC interface, see the following sites: