views:

41

answers:

0

I am trying to get a Connection in the following code and I keep getting an SQLException with the message "Login failed" and with the details "Specified database not found".

Connection con = null;    
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName("com.sybase.jdbc.SybDriver");
dataSource.setUsername("username");
dataSource.setPassword("password");
dataSource.setDefaultAutoCommit(true);
dataSource.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
dataSource.setMaxActive(1);
dataSource.setMaxIdle(1);
dataSource.addConnectionProperty("databaseName", dbName);
dataSource.addConnectionProperty("servicename", dbName);
dataSource.setUrl("jdbc:sybase:Tds:127.0.0.1:2638");
con = dataSource.getConnection();

I have also tried putting the dbName in url and setting it as a property in the url.

dataSource.setUrl("jdbc:sybase:Tds:127.0.0.1:2638/dbName");
dataSource.setUrl("jdbc:sybase:Tds:127.0.0.1:2638?SERVICENAME=dbName");

None of it works. It seems to be seeing the server just fine as the error changes if the url is wrong to just "Connection refused" message.

Any ideas?