chemaxon.jchem.db
Class UpdateHandler

java.lang.Object
  extended by chemaxon.util.ErrorHandler
      extended by chemaxon.jchem.db.UpdateHandler
All Implemented Interfaces:
TableTypeConstants, java.io.Serializable

public class UpdateHandler
extends ErrorHandler
implements TableTypeConstants

Provides methods for handling structure tables, e.g.:

Both fix columns (the ones which have "cd_" prefix in their names) and additional columns can be set using the class.

Example for insert/update:

    int id;          // cd_id value of compound
    // Additional columns:
    String name;
    Float stock;
    String comments;
    ...
    UpdateHandler uh = new UpdateHandler(conh,
            (isInsertion?
                UpdateHandler.INSERT :
                UpdateHandler.UPDATE),
            structureTableName, "name, stock, comments");
    try {

      uh.setStructure(molfile);
        if(!isInsertion) {
            uh.setID(id);    
      } 
        uh.setValueForAdditionalColumn(1, name);
        uh.setValueForAdditionalColumn(2, stock);
        uh.setValueForAdditionalColumn(3, comments);
        uh.execute();
    } finally {
        uh.close();
    }
    ...

This class can be used as an ActiveX component. To avoid problems caused by exceptions in environments where exceptions can not be handled, exceptions are caught and stored using the chemaxon.util.ErrorHandler super class in methods with name like <method name>_NE (where NE means "no exception").

Since method overloading cannot be applied in some environments, overloaded methods have non-overloaded versions that are marked using postfixes in the name. These postfixes include the first letters of the types of parameters. For example, if the parameters of a method are (int, String, int), then the postfix is _ISINE.

Author:
Ferenc Csizmadia, Szilard Dorant
See Also:
Serialized Form

Nested Class Summary
 class UpdateHandler.RowData
           
 
Field Summary
static int INSERT
          Row insertion with automatic cd_id value.
static int INSERT_WITH_ID
          Row insertion with cd_id value set by the application.
static int UPDATE
          Row modification.
 
Fields inherited from class chemaxon.util.ErrorHandler
CLASS_NOT_FOUND_ERROR, DATABASE_SEARCH_ERROR, exception, ILLEGAL_ACCESS_ERROR, INSTANTIATION_ERROR, IO_ERROR, MAX_SEARCH_FREQUENCY_EXCEEDED_ERROR, MOL_FORMAT_ERROR, NO_ERROR, PROPERTY_NOT_SET_ERROR, SQL_ERROR, UNIDENTIFIED_ERROR
 
Fields inherited from interface chemaxon.jchem.db.TableTypeConstants
FP_DEFAULT_BITS_PER_PATTERN, FP_DEFAULT_LENGTH_IN_INTS, FP_DEFAULT_PATTERN_LENGTH, MYSQL_DEFAULT_TABLE_TYPE, MYSQL_FORCE_INNO_DB, MYSQL_FORCE_MYISAM, TABLE_TYPE_ANY_STRUCTURES, TABLE_TYPE_DEFAULT, TABLE_TYPE_EXPLANATIONS, TABLE_TYPE_IS_NOT_SUPPORTED, TABLE_TYPE_MARKUSH_LIBRARIES, TABLE_TYPE_MOLECULES, TABLE_TYPE_NAMES, TABLE_TYPE_QUERY_STRUCTURES, TABLE_TYPE_REACTIONS
 
Constructor Summary
UpdateHandler()
          Zero-arg constructor
UpdateHandler(ConnectionHandler conh, int mode, java.lang.String tableName, java.lang.String additionalColumns)
          Constructor.
UpdateHandler(ConnectionHandler conh, int mode, java.lang.String tableName, java.lang.String additionalColumns, java.lang.String indexedTable, java.lang.String indexedColumn)
          Constructor.
UpdateHandler(java.sql.Connection con, int mode, java.lang.String tableName, java.lang.String additionalColumns)
          Deprecated.  
 
Method Summary
static java.lang.Object checkChemTermColValue(java.lang.Object result)
           
 void close_NE()
          Same as close(), but exceptions are caught and stored.
 void close()
          Closes the handler (required to call).
 UpdateHandler.RowData createRowData(byte[] molString)
          Calcualtes row data from molecule strig.
 UpdateHandler.RowData createRowData(java.lang.String molString)
          Calcualtes row data from molecule strig.
static void createStructureTable(ConnectionHandler conh, java.lang.String tableName, int numberOfInts, int numberOfOnes, int numberOfEdges, java.lang.String columnDefs)
          Deprecated. since JChem 5.0. Please use createStructureTable(chemaxon.util.ConnectionHandler, StructureTableOptions) instead.
static void createStructureTable(ConnectionHandler conh, java.lang.String tableName, int numberOfInts, int numberOfOnes, int numberOfEdges, java.lang.String columnDefs, java.lang.String standardizerConfig, boolean absoluteStereo)
          Deprecated. since JChem 5.0. Please use createStructureTable(chemaxon.util.ConnectionHandler, StructureTableOptions) instead.
static void createStructureTable(ConnectionHandler conh, java.lang.String tableName, int numberOfInts, int numberOfOnes, int numberOfEdges, java.lang.String columnDefs, java.lang.String standardizerConfig, boolean absoluteStereo, java.util.Map chemTermColsCfg, int tableType)
          Deprecated. since JChem 5.0. Please use createStructureTable(chemaxon.util.ConnectionHandler, StructureTableOptions) instead.
static void createStructureTable(ConnectionHandler conh, StructureTableOptions options)
          Creates a structure table.
static void deleteRow(ConnectionHandler conh, java.lang.String tableName, int cd_id)
          Deletes the specified rows from a structure table.
static void deleteRows(ConnectionHandler conh, java.lang.String tableName, java.lang.String where)
          Deletes the specified rows from a structure table.
static void dropStructureTable(ConnectionHandler conh, java.lang.String tableName)
          Drops a structure table.
 void execute_NE()
          Same as execute(), but exceptions are caught and stored.
 int execute_NE(boolean returnLastId)
          Same as execute(boolean returnLastId), but exceptions are caught and stored.
 void execute()
          Executes the update or insert operation.
 int execute(boolean returnLastId)
          Executes the update or insert operation.
 Molecule getMolecule()
          Returns the Molecule that was used during insert or update.
static int getPreferredTableType(Molecule m)
          Returns the preferred table type for the given molecule object.
 boolean getSetChiralFlag()
          Getter for property setChiralFlag.
static java.lang.String[] getStructureTables(ConnectionHandler conh)
          Collects the names of all structures tables in the database (from the records of the JChemProperties table).
 void init_CISSNE(ConnectionHandler conHandler, int mode, java.lang.String tableName, java.lang.String additionalColumns)
          Same as init, but exceptions are caught and stored.
 void init(ConnectionHandler conHandler, int mode, java.lang.String tableName, java.lang.String additionalColumns)
          Initializes the object.
static boolean isInsertable(Molecule m, int tableType, boolean isEmptyStructuresAllowed)
          Decides whether a molecule can be inserted into a table of a given type.
static void recalculateCTColumns(ConnectionHandler ch, java.lang.String tableName, java.lang.String[] columns, ProgressWriter pw)
          Recalcualtes chemical terms in a structure table.
static void recalculateTable(ConnectionHandler ch, java.lang.String tableName, boolean changeStandardization, java.lang.String standardizerConfig, java.util.Map chemTermColCfg, java.lang.Boolean tautomerDuplicateFiltering, ProgressWriter pw)
          Recalcualtes generated values in a structure table.
static void regenerateTable(ConnectionHandler ch, java.lang.String tableName, boolean changeStandardization, java.lang.String standardizerConfig, java.util.Map chemTermColCfg, ProgressWriter pw)
          Deprecated. since JChem 5.0. Please use recalculateTable(chemaxon.util.ConnectionHandler, String, boolean, String, java.util.Map, Boolean, chemaxon.jchem.file.ProgressWriter) instead.
static void regenerateTable(ConnectionHandler ch, java.lang.String tableName, boolean changeStandardization, java.lang.String standardizerConfig, ProgressWriter pw)
          Deprecated. since JChem 5.0. Please use recalculateTable(chemaxon.util.ConnectionHandler, String, boolean, String, java.util.Map, Boolean, chemaxon.jchem.file.ProgressWriter) instead.
static void regenerateTable(ConnectionHandler ch, java.lang.String tableName, ProgressWriter pw)
          Deprecated. since JChem 5.0. Please use recalculateTable(chemaxon.util.ConnectionHandler, String, boolean, String, java.util.Map, Boolean, chemaxon.jchem.file.ProgressWriter) instead.
 void setDuplicateFiltering(boolean filtering)
          Sets if duplicate structures are allowed to be inserted into the database.
 void setEmptyStructuresAllowed(boolean allowed)
          Sets if empty structures are allowed, default is false
 void setID(int id)
          Sets the cd_id value for the structure.
 void setIgnoreChemicalTermsExceptions(boolean ignore)
          Specifies wheather to ignore exceptions during the calcualtion of Chemical Terms columns.
 void setInputMolecule(Molecule mol)
          Specifies the strucure as a Molecule object.
 void setRowData(UpdateHandler.RowData rowData)
          Specifies pre-calculated row data values.
 void setROWID(java.lang.String rowID)
          Sets values for all fix columns in cartridge mode if the mode is INSERT_WITH_ID.
 void setSetChiralFlag(boolean setChiralFlag)
          Sets if chiral flag should be set to true during import.
 void setStandardizationEnabled(boolean allowed)
          Enables or disables standardization.
 void setStructure(byte[] source)
          Sets the source of the input molecule.
 void setStructure(java.lang.String source)
          Sets the source of the input molecule.
 void setValueForAdditionalColumn_ISINE(int index, java.lang.String value, int sqlType)
          Same as setValueForAdditionalColumn(int, Object, int), but value is a String and exceptions are caught and stored.
 void setValueForAdditionalColumn(int index, java.lang.Object value)
          Sets values for all additional columns Type is defined automatically.
 void setValueForAdditionalColumn(int index, java.lang.Object value, int sqlType)
          Sets values for an additional column.
 void setValuesForFixColumns_BNE(byte[] structure)
          Deprecated. since JChem 3.2. Use setStructure(byte[]) instead.
 void setValuesForFixColumns_IBNE(int id, byte[] structure)
          Deprecated. since JChem 3.2. Use setStructure(byte[]) and setID(int) instead.
 void setValuesForFixColumns_ISNE(int id, java.lang.String structure)
          Deprecated. since JChem 3.2. Use setStructure(String) and setID(int) instead.
 void setValuesForFixColumns_SNE(java.lang.String structure)
          Deprecated. since JChem 3.2. Use setStructure(String) instead.
 void setValuesForFixColumns(byte[] structure)
          Deprecated. since JChem 3.2. Use setStructure(String) instead.
 void setValuesForFixColumns(int id, byte[] structure)
          Deprecated. since JChem 3.2. Use setStructure(byte[]) and setID(int) instead.
 void setValuesForFixColumns(int id, java.lang.String structure)
          Deprecated. since JChem 3.2. Use setStructure(String) and setID(int) instead.
 void setValuesForFixColumns(java.lang.String structure)
          Deprecated. since JChem 3.2. Use setStructure(String) instead.
 
Methods inherited from class chemaxon.util.ErrorHandler
checkError, checkException, getError, getErrorMessage, getException, getStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UPDATE

public static final int UPDATE
Row modification.

See Also:
Constant Field Values

INSERT

public static final int INSERT
Row insertion with automatic cd_id value.

See Also:
Constant Field Values

INSERT_WITH_ID

public static final int INSERT_WITH_ID
Row insertion with cd_id value set by the application.

See Also:
Constant Field Values
Constructor Detail

UpdateHandler

public UpdateHandler()
Zero-arg constructor


UpdateHandler

public UpdateHandler(java.sql.Connection con,
                     int mode,
                     java.lang.String tableName,
                     java.lang.String additionalColumns)
              throws java.sql.SQLException,
                     PropertyNotSetException
Deprecated. 

Throws:
java.sql.SQLException
PropertyNotSetException

UpdateHandler

public UpdateHandler(ConnectionHandler conh,
                     int mode,
                     java.lang.String tableName,
                     java.lang.String additionalColumns)
              throws java.sql.SQLException,
                     PropertyNotSetException
Constructor.

Parameters:
conh - ConnectionHandler opened to the database, containing the name of the JChem property table name of the property table.
mode - possible values UPDATE, INSERT, INSERT_WITH_ID. Not all RDBMS-s support INSERT_WITH_ID if cd_id is assigned to be auto incremented,
tableName - name of structure table to be modified
additionalColumns - specify columns that are not created automatically by JChemManager.
Throws:
java.sql.SQLException
PropertyNotSetException

UpdateHandler

public UpdateHandler(ConnectionHandler conh,
                     int mode,
                     java.lang.String tableName,
                     java.lang.String additionalColumns,
                     java.lang.String indexedTable,
                     java.lang.String indexedColumn)
              throws java.sql.SQLException,
                     PropertyNotSetException
Constructor. FOR INTERNAL USE ONLY.

Parameters:
conh - ConnectionHandler opened to the database, containing the name of the JChem property table name of the property table.
mode - possible values UPDATE, INSERT, INSERT_WITH_ID. Not all RDBMS-s support INSERT_WITH_ID if cd_id is assigned to be auto incremented,
tableName - name of structure table to be modified
additionalColumns - specify columns that are not created automatically by JChemManager.
indexedTable - the name of indexed table when used with JChem Cartridge for regular structure tables. Must be null for JChem structure tables.
indexedColumn - the name of indexed column when used with JChem Cartridge for regular structure tables. Must be null for JChem structure tables.
Throws:
java.sql.SQLException
PropertyNotSetException
Since:
JChem JChem 3.0
Method Detail

init

public void init(ConnectionHandler conHandler,
                 int mode,
                 java.lang.String tableName,
                 java.lang.String additionalColumns)
          throws java.sql.SQLException,
                 PropertyNotSetException
Initializes the object. Useful if UpdateHandler is applied as a JavaBean. It should be called immediately after constructing the object.

Parameters:
conHandler - connection handler object.
mode - possible values UPDATE, INSERT, INSERT_WITH_ID. Not all RDBMS-s support INSERT_WITH_ID if cd_id is assigned to be auto incremented,
tableName - name of structure table to be modified
additionalColumns - specify columns that are not created automatically by JChemManager.
Throws:
java.sql.SQLException
PropertyNotSetException
See Also:
ConnectionHandler

init_CISSNE

public void init_CISSNE(ConnectionHandler conHandler,
                        int mode,
                        java.lang.String tableName,
                        java.lang.String additionalColumns)
Same as init, but exceptions are caught and stored. (NE stands for "no exception".)

See Also:
ErrorHandler, init(ConnectionHandler, int, String, String)

getPreferredTableType

public static int getPreferredTableType(Molecule m)
Returns the preferred table type for the given molecule object.

Parameters:
m - The molecule to be imported.
Returns:
One of the following constants
Since:
JChem 3.2.4
See Also:
TableTypeConstants.TABLE_TYPE_MOLECULES, TableTypeConstants.TABLE_TYPE_REACTIONS, TableTypeConstants.TABLE_TYPE_MOLECULES, TableTypeConstants.TABLE_TYPE_MARKUSH_LIBRARIES

isInsertable

public static boolean isInsertable(Molecule m,
                                   int tableType,
                                   boolean isEmptyStructuresAllowed)
Decides whether a molecule can be inserted into a table of a given type.

Parameters:
m - Molecule object to be inserted.
tableType - The type of the table to be inserted into.
isEmptyStructuresAllowed - Is empty structure allowed in the table?
Returns:
true if the molecule is allowed to be inserted into the given table type.
Since:
JChem 3.2.4
See Also:
TableTypeConstants.TABLE_TYPE_MOLECULES, TableTypeConstants.TABLE_TYPE_REACTIONS, TableTypeConstants.TABLE_TYPE_MOLECULES, TableTypeConstants.TABLE_TYPE_QUERY_STRUCTURES, TableTypeConstants.TABLE_TYPE_MARKUSH_LIBRARIES

getMolecule

public Molecule getMolecule()
Returns the Molecule that was used during insert or update.

Returns:
the structure specified in setValuesForFixColumns( ... ) in standardized form, as it was inserted into the database.
NOTE: Should be called only after execute().
Since:
JChem 2.2.1

setInputMolecule

public void setInputMolecule(Molecule mol)
Specifies the strucure as a Molecule object.
Useful, if we already have the structure as an object to save import time.

Parameters:
mol - the Molecule
Since:
JChem 2.3

setROWID

public void setROWID(java.lang.String rowID)
Sets values for all fix columns in cartridge mode if the mode is INSERT_WITH_ID.
FOR INTERNAL USE ONLY.

Parameters:
rowID - the ROWID if the original line in the non-jchem table.

setStructure

public void setStructure(java.lang.String source)
Sets the source of the input molecule.

Parameters:
source - the source of the structure
Since:
JChem 3.2

setStructure

public void setStructure(byte[] source)
Sets the source of the input molecule.

Parameters:
source - the source of the structure
Since:
JChem 3.2

setID

public void setID(int id)
Sets the cd_id value for the structure. Effective in UPDATE or INSERT_WITH_ID mode.

Parameters:
id - the cd_id value
Since:
JChem 3.2

setValuesForFixColumns

public void setValuesForFixColumns(int id,
                                   byte[] structure)
                            throws java.sql.SQLException,
                                   MolFormatException,
                                   UpdateHandlerException
Deprecated. since JChem 3.2. Use setStructure(byte[]) and setID(int) instead.

Sets values for all fix columns if the mode is INSERT_WITH_ID or UPDATE.

Parameters:
id - cd_id value set explicitly. In the case of an update, the row with the given cd_id value will be updated.
structure - Structure source in one of the supported file formats
Throws:
java.sql.SQLException
MolFormatException
UpdateHandlerException

setValuesForFixColumns_IBNE

public void setValuesForFixColumns_IBNE(int id,
                                        byte[] structure)
Deprecated. since JChem 3.2. Use setStructure(byte[]) and setID(int) instead.

Same as setValuesForFixColumns(int, byte[]), but exceptions are caught and stored.

See Also:
ErrorHandler, setValuesForFixColumns(int, byte[])

setValuesForFixColumns

public void setValuesForFixColumns(int id,
                                   java.lang.String structure)
                            throws java.sql.SQLException,
                                   MolFormatException,
                                   UpdateHandlerException
Deprecated. since JChem 3.2. Use setStructure(String) and setID(int) instead.

Sets values for all fix columns, if the mode is INSERT_WITH_ID or UPDATE.

Parameters:
id - cd_id value set explicitly. In the case of an update, the row with the given cd_id value will be updated.
structure - Structure source in one of the supported file formats
Throws:
java.sql.SQLException
MolFormatException
UpdateHandlerException

setValuesForFixColumns_ISNE

public void setValuesForFixColumns_ISNE(int id,
                                        java.lang.String structure)
Deprecated. since JChem 3.2. Use setStructure(String) and setID(int) instead.

Same as setValuesForFixColumns(int, String), but exceptions are caught and stored.

See Also:
ErrorHandler, setValuesForFixColumns(int, String)

setValuesForFixColumns

public void setValuesForFixColumns(byte[] structure)
                            throws java.sql.SQLException,
                                   MolFormatException,
                                   UpdateHandlerException
Deprecated. since JChem 3.2. Use setStructure(String) instead.

Sets values for all fix columns, if the mode is INSERT. cd_id is incremented automatically.

Parameters:
structure - Structure source in one of the supported file formats
Throws:
java.sql.SQLException
MolFormatException
UpdateHandlerException

setIgnoreChemicalTermsExceptions

public void setIgnoreChemicalTermsExceptions(boolean ignore)
Specifies wheather to ignore exceptions during the calcualtion of Chemical Terms columns.

Parameters:
ignore - if set to true, no exceptions will be thrown if a calcualtion for a Chemical Terms column fails. The affected column will have a value of NULL in the database. The default value is false.
Since:
JChem 3.2.6

checkChemTermColValue

public static java.lang.Object checkChemTermColValue(java.lang.Object result)

setValuesForFixColumns_BNE

public void setValuesForFixColumns_BNE(byte[] structure)
Deprecated. since JChem 3.2. Use setStructure(byte[]) instead.

Same as setValuesForFixColumns(byte[]), but exceptions are caught and stored.

See Also:
ErrorHandler, setValuesForFixColumns(byte[])

setValuesForFixColumns

public void setValuesForFixColumns(java.lang.String structure)
                            throws java.sql.SQLException,
                                   MolFormatException,
                                   UpdateHandlerException
Deprecated. since JChem 3.2. Use setStructure(String) instead.

Sets values for all fix columns, if the mode is INSERT. cd_id is incremented automatically.

Parameters:
structure - Structure source in one of the supported file formats
Throws:
java.sql.SQLException
MolFormatException
UpdateHandlerException

setValuesForFixColumns_SNE

public void setValuesForFixColumns_SNE(java.lang.String structure)
Deprecated. since JChem 3.2. Use setStructure(String) instead.

Same as setValuesForFixColumns(String), but exceptions are caught and stored.

See Also:
ErrorHandler, setValuesForFixColumns(String)

setValueForAdditionalColumn

public void setValueForAdditionalColumn(int index,
                                        java.lang.Object value,
                                        int sqlType)
                                 throws java.sql.SQLException
Sets values for an additional column. Call setValuesForFixColumns before invoking this method.

Parameters:
index - the index value of the additional column as listed in the constructor starting at 1.
value - the value of the column in the row. It can also be null if the column is declared as NULL.
sqlType - the type of the column as defined in java.sql.Types
Throws:
java.sql.SQLException

setValueForAdditionalColumn_ISINE

public void setValueForAdditionalColumn_ISINE(int index,
                                              java.lang.String value,
                                              int sqlType)
Same as setValueForAdditionalColumn(int, Object, int), but value is a String and exceptions are caught and stored.

See Also:
ErrorHandler, setValueForAdditionalColumn(int, Object, int)

setValueForAdditionalColumn

public void setValueForAdditionalColumn(int index,
                                        java.lang.Object value)
                                 throws java.sql.SQLException
Sets values for all additional columns Type is defined automatically.

Parameters:
index - the index value of the additional column as listed in the constructor starting at 1.
value - the value of the column in the row.
Throws:
java.sql.SQLException

setEmptyStructuresAllowed

public void setEmptyStructuresAllowed(boolean allowed)
Sets if empty structures are allowed, default is false

Parameters:
allowed - set to true to enable empty srtuctures

setDuplicateFiltering

public void setDuplicateFiltering(boolean filtering)
Sets if duplicate structures are allowed to be inserted into the database.

Parameters:
filtering - set to true to enable filtering. Default setting is false

setSetChiralFlag

public void setSetChiralFlag(boolean setChiralFlag)
Sets if chiral flag should be set to true during import. Useful when importing MDL files with missing chiral flag.

Parameters:
setChiralFlag - if set to true, chiral flag is set to true for imported molecules. The default setting is false. since 2.3

getSetChiralFlag

public boolean getSetChiralFlag()
Getter for property setChiralFlag.

Returns:
the value of property setChiralFlag
See Also:
setSetChiralFlag(boolean)

setStandardizationEnabled

public void setStandardizationEnabled(boolean allowed)
Enables or disables standardization. NOTE: if the structure is not already properly standardized, disabling standardization may have unpredictable effects on search results.

Parameters:
allowed - if false, no standardization is performed when inserting structure. Default is value true.

execute

public void execute()
             throws java.sql.SQLException
Executes the update or insert operation. Same as execute(false)

Throws:
java.sql.SQLException

execute

public int execute(boolean returnLastId)
            throws java.sql.SQLException
Executes the update or insert operation.
Stays in the same transaction if Connection.getAutoCommit()==false

Parameters:
returnLastId - if true, then gets the last inserted ID and returns it.
NOTE: works with ORACLE, DB2, MySQL, MSSQLServer, InterBase, PostgreSQL and MSAccess
Returns:
the last inserted id, or zero if returnLastId is false or the operation is update. If duplicateFiltering is on, returns the cd_id of the already existing structure in the database as a negative value. (regardless of returnLastId).
Throws:
java.sql.SQLException

execute_NE

public void execute_NE()
Same as execute(), but exceptions are caught and stored.

See Also:
ErrorHandler, execute()

execute_NE

public int execute_NE(boolean returnLastId)
Same as execute(boolean returnLastId), but exceptions are caught and stored.

See Also:
ErrorHandler, execute(boolean returnLastId)

close

public void close()
           throws java.sql.SQLException
Closes the handler (required to call). Closes the prepared statements applied and writes the changes to the log table (required for correct cache update).

Throws:
java.sql.SQLException

close_NE

public void close_NE()
Same as close(), but exceptions are caught and stored.

See Also:
ErrorHandler, close()

deleteRows

public static void deleteRows(ConnectionHandler conh,
                              java.lang.String tableName,
                              java.lang.String where)
                       throws java.sql.SQLException
Deletes the specified rows from a structure table. Also deletes the appropriate rows from the corresponding Molecular Descriptor tables, if present and needed. (Referential integrity is used to take care of that for most RDBMSs). This method is best suited to delete large number of rows. The IDs of the deleted structures will not be logged individually, therefore the cache update may take some time after the operation. For deleting a small amount of records using deleteRow(chemaxon.util.ConnectionHandler, String, int) is recommended.

Parameters:
conh - connection to the database
tableName - name of structure table to be modified
where - the WHERE part of the SQL statement deleting the rows. E.g. "WHERE cd_id IN (23, 247, 786)"
Throws:
java.sql.SQLException
See Also:
deleteRow(chemaxon.util.ConnectionHandler, String, int)

deleteRow

public static void deleteRow(ConnectionHandler conh,
                             java.lang.String tableName,
                             int cd_id)
                      throws java.sql.SQLException
Deletes the specified rows from a structure table. Also deletes the appropriate rows from the corresponding Molecular Descriptor tables, if present and needed. (Referential integrity is used to take care of that for most RDBMSs). Use this method to delete relatively small amount of records. The ID of each structure is logged in the update log table providing efficient cache update after the operation. For deleting a large amount of records using deleteRows(chemaxon.util.ConnectionHandler, String, String) is recommended.

Parameters:
conh - connection to the database
tableName - the name of the structure table
cd_id - the cd_id value of the row to be deleted (primary key)
Throws:
java.sql.SQLException
Since:
5.0
See Also:
deleteRows(chemaxon.util.ConnectionHandler, String, String)

getStructureTables

public static java.lang.String[] getStructureTables(ConnectionHandler conh)
                                             throws java.sql.SQLException
Collects the names of all structures tables in the database (from the records of the JChemProperties table).

Parameters:
conh - connection to the database
Throws:
java.sql.SQLException

createStructureTable

public static void createStructureTable(ConnectionHandler conh,
                                        StructureTableOptions options)
                                 throws java.sql.SQLException
Creates a structure table.

Parameters:
conh - connection to the database
options - options for table creation
Throws:
java.sql.SQLException
Since:
JChem 5.0
See Also:
StructureTableOptions

createStructureTable

public static void createStructureTable(ConnectionHandler conh,
                                        java.lang.String tableName,
                                        int numberOfInts,
                                        int numberOfOnes,
                                        int numberOfEdges,
                                        java.lang.String columnDefs)
                                 throws java.sql.SQLException,
                                        PropertyNotSetException
Deprecated. since JChem 5.0. Please use createStructureTable(chemaxon.util.ConnectionHandler, StructureTableOptions) instead.

Creates a structure table. Calls a CREATE TABLE and a CREATE INDEX statement. (cd_id will be a primary key, the cd_fp... columns will be used in the index.) The content of the columnDefs field is inserted into the SQL CREATE statement, before the ending ')' character; The syntax of the columnDefs field Example with suggested chemical hashed fingerprint parameters:
 createStructureTable(con, "structures", 16, 2, 5,
      ", name CHAR(100), stock INTEGER");
 

Parameters:
conh - connection to the database
tableName - name of structure table
numberOfInts - the length of the chemical hashed fingerprint in int size units (bit count / 32)
numberOfOnes - the Bits to be set for patterns
numberOfEdges - the Maximum pattern length
columnDefs - definitions of additional columns
Throws:
java.sql.SQLException
PropertyNotSetException

createStructureTable

public static void createStructureTable(ConnectionHandler conh,
                                        java.lang.String tableName,
                                        int numberOfInts,
                                        int numberOfOnes,
                                        int numberOfEdges,
                                        java.lang.String columnDefs,
                                        java.lang.String standardizerConfig,
                                        boolean absoluteStereo)
                                 throws java.sql.SQLException,
                                        PropertyNotSetException
Deprecated. since JChem 5.0. Please use createStructureTable(chemaxon.util.ConnectionHandler, StructureTableOptions) instead.

Creates a structure table. Calls a CREATE TABLE and a CREATE INDEX statement. (cd_id will be a primary key, the cd_fp... columns will be used in the index.) The content of the columnDefs field is inserted into the SQL CREATE statement, before the ending ')' character; The syntax of the columnDefs field Example with suggested chemical hashed fingerprint parameters:
 createStructureTable(con, "structures", 16, 2, 5,
      ", name CHAR(100), stock INTEGER");
 

Parameters:
conh - connection to the database
tableName - name of structure table
numberOfInts - the length of the chemical hashed fingerprint in int size units (bit count / 32)
numberOfOnes - the Bits to be set for patterns
numberOfEdges - the Maximum pattern length
columnDefs - definitions of additional columns
standardizerConfig - standardization configuration. If null, default standardization is used.
Throws:
java.sql.SQLException
PropertyNotSetException
Since:
JChem 2.2

createStructureTable

public static void createStructureTable(ConnectionHandler conh,
                                        java.lang.String tableName,
                                        int numberOfInts,
                                        int numberOfOnes,
                                        int numberOfEdges,
                                        java.lang.String columnDefs,
                                        java.lang.String standardizerConfig,
                                        boolean absoluteStereo,
                                        java.util.Map chemTermColsCfg,
                                        int tableType)
                                 throws java.sql.SQLException,
                                        PropertyNotSetException
Deprecated. since JChem 5.0. Please use createStructureTable(chemaxon.util.ConnectionHandler, StructureTableOptions) instead.

Creates a structure table. Calls a CREATE TABLE and a CREATE INDEX statement. (cd_id will be a primary key, the cd_fp... columns will be used in the index.) The content of the columnDefs field is inserted into the SQL CREATE statement, before the ending ')' character; The syntax of the columnDefs field
  • starts with a comma
  • contains column definitions separated by comma
  • see the SQL CREATE statement for legal column definions
Example with suggested chemical hashed fingerprint parameters:
 createStructureTable(con, "structures", 16, 2, 5,
      ", name CHAR(100), stock INTEGER");
 

Parameters:
conh - connection to the database
tableName - name of structure table
numberOfInts - the length of the chemical hashed fingerprint in int size units (bit count / 32)
numberOfOnes - the Bits to be set for patterns
numberOfEdges - the Maximum pattern length
columnDefs - definitions of additional columns
standardizerConfig - standardization configuration. If null, default standardization is used.
chemTermColsCfg - map having as keys the names of columns which must be assigned a value (during structure import and update). The values assigned to the columns are calculated using the chemical terms expressions contained in the map as values.
tableType - specifies the type of the structure table. The following options can be specified: The default value is TableTypeConstants.TABLE_TYPE_DEFAULT.
Throws:
java.sql.SQLException
PropertyNotSetException
Since:
JChem 3.2

dropStructureTable

public static void dropStructureTable(ConnectionHandler conh,
                                      java.lang.String tableName)
                               throws java.sql.SQLException
Drops a structure table.

Parameters:
conh - connection to the database
tableName - name of structure table
Throws:
java.sql.SQLException

regenerateTable

public static void regenerateTable(ConnectionHandler ch,
                                   java.lang.String tableName,
                                   ProgressWriter pw)
                            throws java.sql.SQLException,
                                   UpdateHandlerException
Deprecated. since JChem 5.0. Please use recalculateTable(chemaxon.util.ConnectionHandler, String, boolean, String, java.util.Map, Boolean, chemaxon.jchem.file.ProgressWriter) instead.

Regenerates a structure table ( recalculates structure table fields). Molecular Descriptor tables are also regenerated, if present.

Parameters:
ch - ConnectionHandler opened to the database
tableName - the name of the structure table to be regenerated
pw - ProgressWriter for monitoring (and if needed cancelling) the progress of regeneration. May be null if no monitoring is necessary.
Throws:
java.sql.SQLException
UpdateHandlerException
Since:
JChem 2.0

regenerateTable

public static void regenerateTable(ConnectionHandler ch,
                                   java.lang.String tableName,
                                   boolean changeStandardization,
                                   java.lang.String standardizerConfig,
                                   ProgressWriter pw)
                            throws java.sql.SQLException,
                                   UpdateHandlerException
Deprecated. since JChem 5.0. Please use recalculateTable(chemaxon.util.ConnectionHandler, String, boolean, String, java.util.Map, Boolean, chemaxon.jchem.file.ProgressWriter) instead.

Regenerates a structure table ( recalculates structure table fields). Molecular Descriptor tables are also regenerated, if present.

Parameters:
ch - ConnectionHandler opened to the database
tableName - the name of the structure table to be regenerated
pw - ProgressWriter for monitoring (and if needed cancelling) the progress of regeneration. May be null if no monitoring is necessary.
changeStandardization - changes default standardization if true
standardizerConfig - new standardizer configuration, is set to null, default standardization is used
Throws:
java.sql.SQLException
UpdateHandlerException
Since:
JChem 2.2

regenerateTable

public static void regenerateTable(ConnectionHandler ch,
                                   java.lang.String tableName,
                                   boolean changeStandardization,
                                   java.lang.String standardizerConfig,
                                   java.util.Map chemTermColCfg,
                                   ProgressWriter pw)
                            throws java.sql.SQLException,
                                   UpdateHandlerException
Deprecated. since JChem 5.0. Please use recalculateTable(chemaxon.util.ConnectionHandler, String, boolean, String, java.util.Map, Boolean, chemaxon.jchem.file.ProgressWriter) instead.

Regenerates a structure table ( recalculates structure table fields). Molecular Descriptor tables are also regenerated, if present.

Parameters:
ch - ConnectionHandler opened to the database
tableName - the name of the structure table to be regenerated
changeStandardization - changes default standardization if true
standardizerConfig - new standardizer configuration, is set to
chemTermColCfg - colname-to-chemterm map for columns autocalculated based on Chemical Terms. Specify null if there is no change in the column definitions.
pw - ProgressWriter for monitoring (and if needed cancelling) the progress of regeneration. May be null if no monitoring is necessary.
Throws:
java.sql.SQLException
UpdateHandlerException
Since:
JChem 3.2

recalculateTable

public static void recalculateTable(ConnectionHandler ch,
                                    java.lang.String tableName,
                                    boolean changeStandardization,
                                    java.lang.String standardizerConfig,
                                    java.util.Map chemTermColCfg,
                                    java.lang.Boolean tautomerDuplicateFiltering,
                                    ProgressWriter pw)
                             throws UpdateHandlerException
Recalcualtes generated values in a structure table. Molecular Descriptor tables are also recalculated, if present.

Parameters:
ch - ConnectionHandler opened to the database
tableName - the name of the structure table to be regenerated
changeStandardization - changes default standardization if true
standardizerConfig - new standardizer configuration, is set to
chemTermColCfg - colname-to-chemterm map for columns autocalculated based on Chemical Terms. Specify null if there is no change in the column definitions.
tautomerDuplicateFiltering - set to Boolean.TRUE to enable considering tautomers during duplicate filtering. Set to null to keep the current setting (default).
pw - ProgressWriter for monitoring (and if needed cancelling) the progress of regeneration. May be null if no monitoring is necessary.
Throws:
UpdateHandlerException
Since:
JChem 5.0

recalculateCTColumns

public static void recalculateCTColumns(ConnectionHandler ch,
                                        java.lang.String tableName,
                                        java.lang.String[] columns,
                                        ProgressWriter pw)
                                 throws UpdateHandlerException
Recalcualtes chemical terms in a structure table.

Parameters:
ch - ConnectionHandler opened to the database
tableName - the name of the structure table to be regenerated
columns - array of chemical terms column names
pw - ProgressWriter for monitoring (and if needed cancelling) the progress of regeneration. May be null if no monitoring is necessary.
Throws:
UpdateHandlerException
Since:
JChem 5.1.2

createRowData

public UpdateHandler.RowData createRowData(java.lang.String molString)
                                    throws UpdateHandlerException,
                                           MolFormatException
Calcualtes row data from molecule strig.

NOTE: Not thread safe ! Multiple threads should use multiple UpdateHandler instances to call this method.

Parameters:
molString - the source of the structure
Throws:
UpdateHandlerException
MolFormatException
Since:
JChem 3.2
See Also:
setRowData(chemaxon.jchem.db.UpdateHandler.RowData)

createRowData

public UpdateHandler.RowData createRowData(byte[] molString)
                                    throws UpdateHandlerException,
                                           MolFormatException
Calcualtes row data from molecule strig.

NOTE: Not thread safe ! Multiple threads should use multiple UpdateHandler instances to call this method.

Parameters:
molString - the source of the structure
Throws:
UpdateHandlerException
MolFormatException
Since:
JChem 3.2
See Also:
setRowData(chemaxon.jchem.db.UpdateHandler.RowData)

setRowData

public void setRowData(UpdateHandler.RowData rowData)
                throws java.sql.SQLException
Specifies pre-calculated row data values. Subtitutes setValueForFixColumns() and setValueForAdditionalColumn calls. Useful if the data is calculated in a multi-thread environment.

Parameters:
rowData - the RowData object
Throws:
java.sql.SQLException
Since:
JChem 3.2
See Also:
createRowData(String)