简体   繁体   中英

what's the data source url for LDAP type

I am using Spring jdbc api to connect to a Oracle database. Only LDAP style of connection is provided to that particular database, and I succeeded in making the connection from Oracle's database client SQL developer.

One thing seems odd to me is the format of the connection string:

xyz.loc.biz.com:4050:4049

it worked when applied in SQL developer, however you would notice that there are two numbers which supposedly represent port number, but why two?

Nevertheless I used the above url in my code, which looks like:

@Bean
public DataSource getDataSource(){
    SimpleDriverDataSource ds = new SimpleDriverDataSource();
    ds.setUrl("jdbc:oracle:thin:@ldap://xyz.loc.biz.com:4050:4049/...");

    ds.setDriver(new OracleDriver());
    ds.setUsername("xxxxxx");
    ds.setPassword("yyyyyy");

    try(Connection conn = ds.getConnection()){
        log.info("conn={}",conn);
    }catch(Exception e){
        e.printStackTrace();
    };
    return ds;
}

Not surprisingly it shows an error like:

java.lang.NumberFormatException: For input string: "4050:4049"

Anyone can help?

Settings in SQL developer:

在此处输入图片说明

It seems that if you specify two port numbers the first is used for the ldap protocol, the second for the ldaps protocol (found a hint at http://yong321.freeshell.org/oranotes/OracleConnectionSetup.html , the following is more definitive: http://docs.oracle.com/cd/B28359_01/network.111/b28317/ldap.htm ).

It can be that the Oracle JDBC driver does not understand this syntax. Please try if one of these alternative connection strings work for you:

ds.setUrl("jdbc:oracle:thin:@ldap://xyz.loc.biz.com:4050/...");
ds.setUrl("jdbc:oracle:thin:@ldaps://xyz.loc.biz.com:4049/...");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM