User a200fcbc5e
07-04-2011 10:49:41
Hi,
I'm looking to upgrade from JChem v5.4.1.1 from v5.2.6
I'm using the chemaxon.jchem.db.UpdateHandler class. With the code below using v 5.4.1.1, I get the following error.
Am I missing something out from the API or something else I'm doing wrong?
I don't get any errors when I use v5.2.6
Barry
Exception in thread "main" java.sql.SQLException: Attempt to insert null into a non-nullable column: column: CD_PRE_CALCULATED table: ONTOLOGY_TABLE in statement [INSERT INTO ONTOLOGY_TABLE (
CD_STRUCTURE,
CD_SMILES,
CD_FORMULA,
CD_SORTABLE_FORMULA,
CD_MOLWEIGHT,
CD_HASH,
CD_FLAGS,
CD_PRE_CALCULATED,
CD_TIMESTAMP,
CD_FP1,
CD_FP2,
CD_FP3,
CD_FP4,
CD_FP5,
CD_FP6,
CD_FP7,
CD_FP8,
CD_FP9,
CD_FP10,
CD_FP11,
CD_FP12,
CD_FP13,
CD_FP14,
CD_FP15,
CD_FP16) VALUES (?,?,?,?,?,?,?,?,NOW(),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
at chemaxon.jchem.db.UpdateHandler.execute(UpdateHandler.java:2347)
at chemaxon.jchem.db.UpdateHandler.execute(UpdateHandler.java:2240)
at toyJChem.JChemDemo.main(JChemDemo.java:31)
======================
package toyJChem;
import java.sql.Connection;
import java.sql.SQLException;
import chemaxon.formats.recognizer.SMILESRecognizer;
import chemaxon.jchem.db.DatabaseProperties;
import chemaxon.jchem.db.StructureTableOptions;
import chemaxon.jchem.db.TableTypeConstants;
import chemaxon.jchem.db.UpdateHandler;
import chemaxon.util.ConnectionHandler;
public class JChemDemo
{
public static final String TABLE_NAME = "ONTOLOGY_TABLE";
public static final String NODE_ID_COLUMN_NAME = "node_id";
public static final String ORIGINAL_SMILES_COLUMN_NAME = "original_smiles";
private static Connection connection;
private static ConnectionHandler conn_handler;
public static void main (String[] args) throws Exception
{
init();
createTables();
UpdateHandler handler = new UpdateHandler(conn_handler, UpdateHandler.INSERT, JChemDemo.TABLE_NAME , null);
if ( SMILESRecognizer.canBeSMILES( "CC(=O)NCCC=O" ))
{
handler.setStructure( "CC(=O)NCCC=O" );
handler.execute();
}
}
private static void init() throws Exception
{
connection = ConnectionFactory.getConnection();
conn_handler = new ConnectionHandler();
conn_handler.setConnection( connection );
}
private static void createTables() throws SQLException
{
DatabaseProperties.createPropertyTable(conn_handler);
createTable();
}
private static void createTable() throws SQLException
{
StructureTableOptions tableOptions = new StructureTableOptions();
tableOptions.name = JChemDemo.TABLE_NAME;
tableOptions.tableType = TableTypeConstants.TABLE_TYPE_ANY_STRUCTURES;
// Setting finger print parameters according to table type
tableOptions.fp_numberOfInts = TableTypeConstants.FP_DEFAULT_LENGTH_IN_INTS[tableOptions.tableType];
tableOptions.fp_numberOfOnes = TableTypeConstants.FP_DEFAULT_BITS_PER_PATTERN[tableOptions.tableType];
tableOptions.fp_numberOfEdges = TableTypeConstants.FP_DEFAULT_PATTERN_LENGTH[tableOptions.tableType];
UpdateHandler.createStructureTable(conn_handler, tableOptions);
}
}