NullPointerException during recalculateTable with jchem5.1.4

User eb7d5cd1ec

17-02-2009 09:26:36

Hi,





I'v upgraded the JChem installation from 5.0.0 to 5.1.4, regenerated structure tables with jcman successfully, and replaced the jchem.jar file. however, i got the following NullPointerException during recalculate tables .











Code:
UpdateHandler.recalculateTable(ch, tab_name, false, null, null, null, null);









 it works well with jchem5.0.0. The API have changed?(however,there is no change in jchem doc for recalculateTable)  or I missed some necessary setting? Can you help with this ?





java.lang.NullPointerException


 at java.lang.Class.forName0(Native Method)


 at java.lang.Class.forName(Class.java:164)


 at chemaxon.util.ConnectionHandler.setConnected(ConnectionHandler.java:196)


 at chemaxon.util.ConnectionHandler.connect(ConnectionHandler.java:234)


 at chemaxon.jchem.db.Regenerator.run(Regenerator.java:263)


 at chemaxon.jchem.db.UpdateHandler.recalculateTable(UpdateHandler.java:3180)


 ……


 ……


chemaxon.jchem.db.UpdateHandlerException: java.sql.SQLException


Caused by:


java.sql.SQLException


 at chemaxon.jchem.db.UpdateHandler.recalculateTable(UpdateHandler.java:3183)


 ……


 ……





Many thanks,





lsqsusu

ChemAxon aa7c50abf8

17-02-2009 11:03:57

Hi lsqsusu,








You may get a similar error, if the ConnectionHandler instance you are passing to UpdateHandler was not "connected" using the "setConnected(true)" method, but uses a Connection instance which has been set on it using the "setConnection(Connection)" method.





In summary: try initializing the the ConnectionHandler instance by





1. setting all connection properties (class, url, login, password) and








2. calling setConnected(true)





Thanks





Peter

User eb7d5cd1ec

18-02-2009 03:28:47

Thanks for your answer.





i had used "ch.setConnection(Connection)" method for all of the operations, and it works well for search and update with jchem5.1.4 ,except recalculateTable. by the way, recalculateTable works well with 5.0.0.





i'm sure the Connection have been set to ConnectionHandler.





>2. calling setConnected(true)  





i tried to call ch.setConnected(true) after ch.setConnection(Connection), there is another NullPointerException during setConnected(true)





java.lang.NullPointerException


 at java.lang.Class.forName0(Native Method)


 at java.lang.Class.forName(Class.java:164)


 at chemaxon.util.ConnectionHandler.setConnected(ConnectionHandler.java:196)





Thanks

User eb7d5cd1ec

18-02-2009 04:47:49

maybe i misunderstood what you said about "setting all connection properties (class, url, login, password)"


instead of ch.setConnection(Connection), i have tried this like the code below, and it succeeded in UpdateHandler.recalculateTable(ch, tab_name, false, null, null, null, null) .








Code:
 ch.setDriver("oracle.jdbc.driver.OracleDriver");


    ch.setUrl("jdbc:oracle:thin:@localhost:1521:sid");


    ch.setLoginName(loginName);


    ch.setPassword(password);


    ch.connect(); 











but why didn't ch.setConnection(Connection) work well for UpdateHandler.recalculateTable(ch, tab_name, false, null, null, null, null) in jchem5.1.4?





i have defined datasource for getting the Connection, it is desirable that i can still use ch.setConnection(Connection), can you help with this?





Thanks

ChemAxon 9c0afc9aaf

18-02-2009 05:41:14

Hi,





The reason why setConnection() is not enough in this case is that we are creating multiple connections, so the regeneration can be faster on multiple threads.


We are aware that this is not comfortable in case of DataSources, and we plan to implement a better solution and also make the API less ambiguous.


It is currently scheduled for JChem 5.3 - about half a year from now.


Until then you have to specify all connection parameters.





Best regards,





Szilard

User eb7d5cd1ec

18-02-2009 06:24:32

Thank you for your answer. I will give up setConnection(Connection).