jchem.db.Exporter produces NullPointerException

User 26d9368720

01-08-2013 14:10:43

Hi,


With version  6.0.3 we have problem when use export with custom sql. Simplified test case below:



ConnectionHandler jchem_con = new ConnectionHandler();


jchem_con.setConnection(c);


jchem_con.setPropertyTable("jchemprops");



Exporter exp = new Exporter();


exp.setFormat(Transfer.SDFILE);



exp.setConnectionHandler(jchem_con);


exp.setSelectStatement("select 'CCCC' as CD_STRUCTURE, 0 as CD_ID from dual");


ByteArrayOutputStream out = new ByteArrayOutputStream();


exp.setOutputStream(out );


Integer molNumber = exp.writeAll();



Last instruction writeAll throws chemaxon.jchem.db.TransferException: Unexpected error during DB export init: null, cause NullPointerException.


We variated with setSelectStatement: used selection from registered structure table like 


select * from jsmiles_bb limit 1 or select CD_STRUCTURE,  CD_ID from jsmiles_bb limit 1


result the same..


When instead of setSelectStatement use setTableName('jsmiles_bb ') the above code works. 


We did nod find in docs any special hints except CD_STRUCTURE must be first in field list. So what's wrong?

ChemAxon d26931946c

02-08-2013 08:41:41

Hi,


 


I've moved your topic to the appropriate forum. My colleauges will answer you soon.


BRs,


Peter

ChemAxon abe887c64e

02-08-2013 12:06:24

Hi,


Could you send us the log file with the stack trace?


Thank you,


Krisztina

User 26d9368720

02-08-2013 12:52:59

code sample:


 



package org.Shop.Utils;


 


import java.io.*;


import java.sql.DriverManager;


import java.sql.PreparedStatement;


import java.sql.Connection;


import java.sql.SQLException;


import chemaxon.util.ConnectionHandler;


import chemaxon.formats.MolImporter;


import chemaxon.jchem.db.*;


public class Updater


{


 public static void main(String[] args)


    {


        try


        {


            Connection connection = DriverManager.getConnection("jdbc:mysql://spectra:3306/Shop", "root", "root");


            ConnectionHandler jchem_con = new ConnectionHandler();


            jchem_con.setConnection(connection);


            jchem_con.setPropertyTable("jchemprops");


 


            Exporter exp = new Exporter();


            exp.setFormat(Transfer.SDFILE);


            exp.setConnectionHandler(jchem_con);


            exp.setSelectStatement("select 'CCCC' as CD_STRUCTURE, 0 as CD_ID from dual");


            ByteArrayOutputStream out = new ByteArrayOutputStream();


            exp.setOutputStream(out);


            Integer molNumber = exp.writeAll();


        }


        catch (Exception ex)


        {


            ex.printStackTrace();


        }


}



result:



chemaxon.jchem.db.TransferException: Unexpected error during DB export init: null


at chemaxon.jchem.db.Exporter.init(Exporter.java:501)


at chemaxon.jchem.db.Exporter.writeAll(Exporter.java:418)


at org.Shop.Utils.Updater.main(Updater.java:491)


Caused by: java.lang.NullPointerException


at chemaxon.jchem.base.persist.impl.sql.SqlCollectionPhysicalConfiguration.getNameWithSchema(SqlCollectionPhysicalConfiguration.java:90)


at chemaxon.jchem.base.persist.impl.sql.SqlCollectionPhysicalConfiguration.getNameWithSchema(SqlCollectionPhysicalConfiguration.java:82)


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


at chemaxon.jchem.db.DatabaseProperties.tablePrefix(DatabaseProperties.java:1096)


at chemaxon.jchem.db.DatabaseProperties.getTableType(DatabaseProperties.java:1390)


at chemaxon.jchem.db.SQLToFileHandler.<init>(SQLToFileHandler.java:114)


at chemaxon.jchem.db.Exporter.init(Exporter.java:495)


... 2 more



ChemAxon abe887c64e

02-08-2013 13:19:40

Thank you for the details. We could reproduce the erroneous behavior. We will inform about the version number of JChem which will contain the bugfix.


Best regards,


Krisztina

ChemAxon 61b4fee994

05-08-2013 08:06:12

Hi,


I can confirm that the fix will be released in the 6.0.4 and the 6.1 versions. The 6.0.4 version will be released in a few days time.


Regards,


Tamas

ChemAxon 61b4fee994

12-08-2013 13:58:06

Hi,


JChem 6.0.4 has been released with the fix.


Regards,


Tamas