GWT JDBC LDAP connection fails

女生的网名这么多〃 提交于 2019-12-06 15:16:23

问题


I am trying to connect my GWT application to an ldap server using jdbc, but could not make it work so far.

Here is a code sample of my attempt to connect to it:

    String ldapConnectString = "jdbc:ldap://SERVERIP:389/dc=SERVERNAME,dc=office,dc=COMPANY,dc=com?SEARCH_SCOPE:=subTreeScope";
    java.sql.Connection con;
    try {
        con = DriverManager.getConnection(ldapConnectString,"cn=USERNAME","PASSWORD");

    } catch (SQLException e) {
        System.out.println("An error has ocurred!!!  Connection failed");
        e.printStackTrace();
    }

The example I used to write this is: http://myvd.sourceforge.net/bridge.html

When I run the application I get following error message:

java.sql.SQLException: No suitable driver found for jdbc:ldap://SERVERIP:389/dc=SERVERNAME,dc=office,dc=COMPANY,dc=com?SEARCH_SCOPE:=subTreeScope

I would be thankful for any help

Edit: The code sample I provided is running on server side accessed by RPC. I included 2 jar files in my lib/ directory downloaded from here: http://sourceforge.net/projects/myvd/files/jdbc%20ldap%20bridge/jdbc%20ldap%20bridge%202.1/jdbc-ldap-2.1.zip/download


回答1:


You generally need to register the JDBC driver before you can connect to the backend.

Try something like

DriverManager.registerDriver(new com.octetstring.jdbcLdap.sql.JdbcLdapDriver());

before setting up the connection.

More general information on ways of registering drivers.



来源:https://stackoverflow.com/questions/6383981/gwt-jdbc-ldap-connection-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!