User 9d2c03e26a
11-06-2010 04:19:34
As far as I found, the jchem cache creation will ignore the connection object even if a valid java.sql.Connection object is given:
ConnectionHandler ch = new ConnectionHandler();
ch.setConnection(connection);
The stacktrace is like this:
java.sql.SQLException: The url cannot be null
at java.sql.DriverManager.getConnection(DriverManager.java:502)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at chemaxon.jchem.db.CacheRegistrationUtil.registerCache(CacheRegistrationUtil.java:77)
at chemaxon.jchem.db.CacheRegistrationUtil.registerPermanentCache(CacheRegistrationUtil.java:61)
We need to exlicitly set the connection paramters again and call connect() on the object:
ch.setDriver(driver);
ch.setUrl(url);
ch.setLoginName(login);
ch.setPassword(password);
ch.setRememberPassword(rememberPassword);
try {
ch.connect();
} catch (Throwable t) {
t.printStacktrace();
}
However, for other JChem operations like get structure table names, using UpdateHandler, an active connection will be enough to do the job.
Is this behavior designed to be like this (on purpose)? or did I miss something important?