Reputation: 1175
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:
Upvotes: 0
Views: 2869
Reputation: 21490
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/...");
Upvotes: 1