Null Exception - Importer , TableInfo.getTableNameWithSchema

User 79bcc43be0

07-03-2009 23:15:57

Hi i´m having troubles with the Importer:

















Importer imp = new Importer();





imp.setConnectionHandler(getDataSource());





imp.setTableName(TABLE);





imp.setInput(file.getInputStream());





imp.setStoreImportedIDs(true);





System.out.println("Collecting file information ...");





imp.init();

















I get the following error:








java.lang.NullPointerException





at chemaxon.jchem.db.TableInfo.getTableNameWithSchema(TableInfo.java:759)





at chemaxon.jchem.db.Importer.init(Importer.java:603)





at chemaxon.jchem.db.Importer.run(Importer.java:370)


























Can anyone shed some light on what is happening when you set the TableName with schema? I have a table called "MOLECULES" that i am passing correct from a constant "TABLE".














This was working fine and all of a sudden i keop getting these errors.














Is there something wrong with my connectionhandler?














I extended it so I could serialize it:

















import java.io.Serializable;





import java.sql.SQLException;























import chemaxon.util.ConnectionHandler;














public class JChemDataSource extends ConnectionHandler implements Serializable {














public JChemDataSource() {





super();











}











public JChemDataSource(String driver,String url,String loginName,String password) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {





super();





System.out.println("Driver="+driver+" url="+url+" loginName="+loginName+" password="+password);





setDriver(driver);





setUrl(url);





setLoginName(loginName);





setPassword(password);





connect();





System.out.println("Initialized connection to structures database.");





}

















}

ChemAxon fa971619eb

08-03-2009 10:18:59

I moved this to the "Storage & search: JChem Base /Cartridge" forum as it is not related to Instant JChem, and you will get a better answer in that forum.


I also reformatted the post as some bad HTML tags were making it difficult to read.





As a quick guess I would check that your JChemDataSource is properly connected. These sorts of errors often come from when the ConnectionHandler is is configured but has not opened a connection to the database. It does look like you call connect() method, but try using setConnected(true) instead. You can use isConnected() to test.


People on the JChem forum might be able to give you a better answer.





Tim

ChemAxon 9c0afc9aaf

08-03-2009 18:08:20

Hi,





You did not report the JChem version, so I cannot be certain, but it seems to me that the ConnectionHandler is not connected, the java.sql.Connection object might be null.


Please call ConnectionHandler.connect() before using it.





Best regards,





Szilard