I am successfullt able to connect to sybase db using jconnect4 lib & bcpkix-jdk15on and below code
import com.sybase.jdbc4.jdbc.SybDataSource;
import java.sql.Connection;
import java.sql.SQLException;
public class SybaseConnectionManager {
public static Connection getSybaseConnection(String serverName, String databaseName, String userName, String password, String url) throws DataGeneratorException {
SybDataSource ds = new SybDataSource();
try {
ds.setServerName(serverName);
ds.setDatabaseName(databaseName);
ds.setUser(userName);
ds.setPassword(password);
// Splitting URL by semicolon
String[] params = url.split(";");
for (String param : params) {
String[] props = param.split("=");
switch (props[0].toUpperCase()) {
case "PORT":
ds.setPortNumber(Integer.parseInt(props[1]));
break;
case "ENCRYPT_PASSWORD":
ds.setENCRYPT_PASSWORD(props[1]);
break;
case "RETRY_WITH_NO_ENCRYPTION":
ds.setRETRY_WITH_NO_ENCRYPTION(props[1]);
break;
case "JCE_PROVIDER_CLASS":
ds.setJCE_PROVIDER_CLASS(props[1]);
break;
}
}
// Get the connection
Connection con = ds.getConnection();
con.setAutoCommit(false);
return con;
} catch (SQLException e) {
log.error("Handling Sybase Exception", e);
throw new DataGeneratorException(e.getMessage());
}
}
I tried connecting to sybase db using jtds lib but getting error "Adaptive Server requires encryption of the login password on the network". I created jdbc url for jtds like below
jdbc:jtds:sybase://<hostname>:<portno>/<dbname>
conn prop below:--
user:
password:
encrypt_password:
retry_with_no_encryyption:
jce_provider_class:
why I'm trying to connect with sybase because of this issue jconnect4 with ojdbcx lib giving noclassfounderror in linux server when used in single application. Getting ClassNotFoundError for oracle and sybase db connection in linux server, but in local wndows eclipse it is working fine