chemaxon.jchem.db
Class DatabaseProperties

java.lang.Object
  extended by chemaxon.jchem.db.DatabaseProperties
All Implemented Interfaces:
TableTypeConstants

public class DatabaseProperties
extends java.lang.Object
implements TableTypeConstants

Methods for reading and writing the JChemProperties table that contains information about the database and the structure tables. The content the JChemProperties table informs JChem how to

The table has 2 columns:
name Keys that are used to access the value.
value. The value of the property.

Author:
Ferenc Csizmadia, Szilard Dorant

Field Summary
static java.lang.String DEFAULT_PROPERTY_TABLE
          The default name of the property table (JChemProperties).
static java.lang.String NAME_COLUMN
          The name of the key column (prop_name).
static java.lang.String VALUE_COLUMN
          The name of the value column (prop_value).
static java.lang.String VALUE_COLUMN_EXT
          The name of the value column extension (prop_value_ext).
 
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
DatabaseProperties(java.sql.Connection con)
          Deprecated. Use DatabaseProperties(ConnectionHandler) instead.
DatabaseProperties(ConnectionHandler conh)
          Constructs an instance for use with JChem structure tables.
DatabaseProperties(ConnectionHandler conh, boolean indexTable)
          Used internally for use with JChem Cartridge index tables.
 
Method Summary
 void addProperty(java.lang.String name, java.lang.String value)
          Inserts the property with the specified key and value If the specified value is null, the property is deleted.
 void close()
          Should be called only if the use of prepared statements are enabled with setUsePreparedStatement(boolean).
static void createPropertyTable(ConnectionHandler conh)
          Creates a new property table for storing JChem's settings.
static void createPropertyTable(ConnectionHandler conh, int mySqlTableType)
          Creates a new property table for storing JChem's settings.
 void deleteChemTermForColumn(java.lang.String tableName, java.lang.String columnName)
          Deletes the property defining the Chemical Terms expression that should be used to compute the value for the given column.
 void deleteProperty(java.lang.String name)
          Removes the row with the specified key from the JChemProperties table, if it exists.
 java.lang.String[] getChemTermColumns(java.lang.String tableName)
          Returns the name of columns with values automatically calculated based on Chemical Terms expressions.
 java.lang.String getChemTermForColumn(java.lang.String tableName, java.lang.String columnName)
          Gets the Chemical Terms expression that should be used to compute the value for the given column.
 int getIntProperty(java.lang.String name)
          Searches for the property with the specified key in the JChemProperties table.
 java.lang.String getProperty(java.lang.String name)
          Searches for the property with the specified key in the JChemProperties table.
 java.util.Vector getStructureTableNames()
          Returns the names of structure tables registered in the JChemProperties table.
 java.util.Vector getStructureTableNames(boolean indexTables)
          Deprecated. Use getStructureTableNames() in conjunction with DatabaseProperties(ConnectionHandler, boolean) to indicate whether the names of JChem structure tables or JChem Cartridge index tables are to be retrieved.
 java.lang.String[] getSynthesisStructureTableNames()
          Retrieves the names of structure tables belonging to stored synthesises
 int getTableType(java.lang.String tableName)
          Returns the type of the specified table.
 long incrementProperty(java.lang.String name)
          Increments the value of property with the specified key by one.
 boolean isTautomerDuplicateFilteringEnabled(java.lang.String tableName)
          Returns whether tautomers are considered during duplicate filtering for this table.
 boolean isUsePreparedStatement()
           
static boolean propertyTableExists(ConnectionHandler conh)
          Checks if JChem property table exists.
 void setChemTermForColumn(java.lang.String tableName, java.lang.String columnName, java.lang.String expression)
          Sets the Chemical Terms expression that should be used to compute the value for the given column.
 void setProperty(java.lang.String name, java.lang.String value)
          Sets the property with the specified key and value in the JChemProperties table.
 void setUsePreparedStatement(boolean usePreparedStatement)
          Specifies if PreparedStatement should be used for property lookup.
 void updateProperty(java.lang.String name, java.lang.String value)
          Updates the property with the specified key and value in the JChemProperties table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PROPERTY_TABLE

public static java.lang.String DEFAULT_PROPERTY_TABLE
The default name of the property table (JChemProperties).


NAME_COLUMN

public static final java.lang.String NAME_COLUMN
The name of the key column (prop_name).

See Also:
Constant Field Values

VALUE_COLUMN

public static final java.lang.String VALUE_COLUMN
The name of the value column (prop_value).

See Also:
Constant Field Values

VALUE_COLUMN_EXT

public static final java.lang.String VALUE_COLUMN_EXT
The name of the value column extension (prop_value_ext).

See Also:
Constant Field Values
Constructor Detail

DatabaseProperties

public DatabaseProperties(java.sql.Connection con)
                   throws java.sql.SQLException
Deprecated. Use DatabaseProperties(ConnectionHandler) instead.

Assumes, that the name of the JChem property table is "JChemProperties".

Parameters:
con - the JDBC connection.
Throws:
java.sql.SQLException

DatabaseProperties

public DatabaseProperties(ConnectionHandler conh)
                   throws java.sql.SQLException
Constructs an instance for use with JChem structure tables.

Parameters:
conh - the ConnectionHandler object that contains at least a valid JDBC connection and property table name.
Throws:
java.sql.SQLException

DatabaseProperties

public DatabaseProperties(ConnectionHandler conh,
                          boolean indexTable)
                   throws java.sql.SQLException
Used internally for use with JChem Cartridge index tables.

Parameters:
conh - the ConnectionHandler object that contains at least a valid JDBC connection and property table name.
indexTable - true if this instance is to be used with JChem Cartridge index tables, false other wise.
Throws:
java.sql.SQLException
Since:
JChem 5.0
Method Detail

getProperty

public java.lang.String getProperty(java.lang.String name)
                             throws java.sql.SQLException
Searches for the property with the specified key in the JChemProperties table. If value is null, retruns the extended value.

Parameters:
name - the property key.
Returns:
the value in this property list with the specified key value, or null if the property doesn't exist.
Throws:
java.sql.SQLException

getIntProperty

public int getIntProperty(java.lang.String name)
                   throws java.sql.SQLException
Searches for the property with the specified key in the JChemProperties table.

Parameters:
name - the property key.
Returns:
the value converted to int, or Integer.MINVALUE, if not found in the table or cannot be parsed as a number
Throws:
java.lang.NullPointerException - if the property doesn't exist
java.sql.SQLException

addProperty

public void addProperty(java.lang.String name,
                        java.lang.String value)
                 throws java.sql.SQLException
Inserts the property with the specified key and value If the specified value is null, the property is deleted. into the JChemProperties table.

Parameters:
name - the property key.
value - the property value. If null, the property is deleted.
Throws:
java.sql.SQLException

updateProperty

public void updateProperty(java.lang.String name,
                           java.lang.String value)
                    throws java.sql.SQLException
Updates the property with the specified key and value in the JChemProperties table. If the specified value is null, the property is deleted.

Parameters:
name - the property key.
value - the property value. If null, the property is deleted.
Throws:
java.sql.SQLException

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
                 throws java.sql.SQLException
Sets the property with the specified key and value in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted. If the specified value is null, the property is deleted.

Parameters:
name - the property key.
value - the property value. If null, the property is deleted.
Throws:
java.sql.SQLException

incrementProperty

public long incrementProperty(java.lang.String name)
                       throws java.sql.SQLException
Increments the value of property with the specified key by one. Value has to be in integer format. If the property doesn't exist with the specified name, then a row with the value 1 is inserted.

Parameters:
name - the property key.
Returns:
the new value of the property
Throws:
java.sql.SQLException

deleteProperty

public void deleteProperty(java.lang.String name)
                    throws java.sql.SQLException
Removes the row with the specified key from the JChemProperties table, if it exists.

Parameters:
name - the property key.
Throws:
java.sql.SQLException

propertyTableExists

public static boolean propertyTableExists(ConnectionHandler conh)
Checks if JChem property table exists.

Parameters:
conh - must contain at minimum a live connection and a property table name

createPropertyTable

public static void createPropertyTable(ConnectionHandler conh)
                                throws java.sql.SQLException
Creates a new property table for storing JChem's settings. It is recommended to test first if the table exists, by calling propertyTableExists

Parameters:
conh - it should contain at minimum a live connection and a property table name If your database server type is MySql, recommend to use the other createPropertyTable method
Throws:
java.sql.SQLException
See Also:
createPropertyTable(ConnectionHandler, int)

createPropertyTable

public static void createPropertyTable(ConnectionHandler conh,
                                       int mySqlTableType)
                                throws java.sql.SQLException
Creates a new property table for storing JChem's settings. It is recommended to test first if the table exists, by calling propertyTableExists

Parameters:
conh - it should contain at minimum a live connection and a property table name
mySqlTableType - table type for MySQL, for other RDBMS ignored. Accepted values:

getStructureTableNames

public java.util.Vector getStructureTableNames()
                                        throws java.sql.SQLException
Returns the names of structure tables registered in the JChemProperties table.

Throws:
java.sql.SQLException

getStructureTableNames

public java.util.Vector getStructureTableNames(boolean indexTables)
                                        throws java.sql.SQLException
Deprecated. Use getStructureTableNames() in conjunction with DatabaseProperties(ConnectionHandler, boolean) to indicate whether the names of JChem structure tables or JChem Cartridge index tables are to be retrieved.

Returns the names of structure tables registered in the JChemProperties table.

Parameters:
indexTables - set to true to get the list of cartridge index tables.
Throws:
java.sql.SQLException
Since:
JChem 3.0

getSynthesisStructureTableNames

public java.lang.String[] getSynthesisStructureTableNames()
                                                   throws java.sql.SQLException
Retrieves the names of structure tables belonging to stored synthesises

Returns:
the table names
Throws:
java.sql.SQLException

isUsePreparedStatement

public boolean isUsePreparedStatement()

setUsePreparedStatement

public void setUsePreparedStatement(boolean usePreparedStatement)
Specifies if PreparedStatement should be used for property lookup. Recommended if properties are read from the table very frequently. NOTE: If set to true, close() should be called after usage.

Parameters:
usePreparedStatement - set to true to use preapared statements for reading data. Default is false

getChemTermColumns

public java.lang.String[] getChemTermColumns(java.lang.String tableName)
                                      throws java.sql.SQLException
Returns the name of columns with values automatically calculated based on Chemical Terms expressions.

Parameters:
tableName - the table, the Chemical Terms-based columns of which should be returned.
Returns:
the name of columns with values automatically calculated based on Chemical Terms expressions.
Throws:
java.sql.SQLException
Since:
3.2

setChemTermForColumn

public void setChemTermForColumn(java.lang.String tableName,
                                 java.lang.String columnName,
                                 java.lang.String expression)
                          throws java.sql.SQLException
Sets the Chemical Terms expression that should be used to compute the value for the given column.

Parameters:
tableName - name of the table containing the column
columnName - name fo the column with pre-computed Chemical Terms values.
expression - the Chemical Terms expression that should be used to compute the value for the given column.
Throws:
java.sql.SQLException
Since:
3.2

getChemTermForColumn

public java.lang.String getChemTermForColumn(java.lang.String tableName,
                                             java.lang.String columnName)
                                      throws java.sql.SQLException
Gets the Chemical Terms expression that should be used to compute the value for the given column.

Parameters:
tableName - name of the table containing the column
columnName - name fo the column with pre-computed Chemical Terms values.
Returns:
the Chemical Terms expression that should be used to compute the value for the given column.
Throws:
java.sql.SQLException
Since:
3.2

deleteChemTermForColumn

public void deleteChemTermForColumn(java.lang.String tableName,
                                    java.lang.String columnName)
                             throws java.sql.SQLException
Deletes the property defining the Chemical Terms expression that should be used to compute the value for the given column.

Parameters:
tableName - name of the table containing the column
columnName - name fo the column with pre-computed Chemical Terms values.
Throws:
java.sql.SQLException
Since:
3.2

getTableType

public int getTableType(java.lang.String tableName)
                 throws java.sql.SQLException
Returns the type of the specified table.

Parameters:
tableName - the name of the JChem structure table
Returns:
one of the following:
Throws:
java.sql.SQLException
Since:
JChem 3.2

isTautomerDuplicateFilteringEnabled

public boolean isTautomerDuplicateFilteringEnabled(java.lang.String tableName)
                                            throws java.sql.SQLException
Returns whether tautomers are considered during duplicate filtering for this table.

Parameters:
tableName - the name of the JChem structure table
Returns:
true if tautomer duplicate filtering is enabled for the table
Throws:
java.sql.SQLException
Since:
JChem 5.0

close

public void close()
           throws java.sql.SQLException
Should be called only if the use of prepared statements are enabled with setUsePreparedStatement(boolean).

Throws:
java.sql.SQLException