Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to use Oracle JDBC driver to access an LDAP server ?

David Le BorgneNov 9 2007 — edited Sep 4 2008
Hello,

I'm trying to use Oracle JDBC driver 10.1.0.5 to access my LDAP server. After reading
http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/urls.htm#CHDBICFA

I wrote the following code:
import oracle.jdbc.pool.OracleDataSource;
import java.sql.Connection;
import java.util.Properties;

public class TestLdap {

  private static OracleDataSource ods;
  private static Connection cnx;

  public static void main (String args[]) {

    Properties prop = new Properties();
    String url = "jdbc:oracle:thin:@ldap://ldap-server:389/";

    try {
      ods = new OracleDataSource();
      ods.setURL(url);
      ods.setConnectionCachingEnabled(true);
      cnx = ods.getConnection("CN=Admin,O=COHERIS,C=FR", "password");
    } catch (java.sql.SQLException se) {
      se.printStackTrace();
    }
  }
}
It fails with java.sql.SQLException: Exception d'E/S: JNDI Package failurejavax.naming.InvalidNameException: cn=: [LDAP: error code 34 - Invalid DN Syntax]; remaining name 'cn='

I have tried many different URLs, but couldn't get a working Connection.
My LDAP server is Domino 6.5, but I did some testing with OpenLDAP 2.0 and had the same results.

Does anyone has an example ? This Oracle JDBC driver feature seems quite uncommon, and I couldn't find any example on the Internet.

Thanks
David Le Borgne
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 2 2008
Added on Nov 9 2007
4 comments
16,566 views