Class DatabaseProperties

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

@PublicAPI public class DatabaseProperties extends Object implements TableTypeConstants
Methods for reading and writing the JChemProperties table that contains information about the database and the structure tables. The content of the JChemProperties table informs JChem how to

The table has 3 columns:

Property table contents
prop_name Key column (stores the name of each property which is used as a unique key).
prop_value. Basic value column (short values are stored here).
prop_value_ext. Extended value column (large values are stored here).

  • Field Details

  • Constructor Details

    • DatabaseProperties

      @Deprecated public DatabaseProperties(ConnectionHandler conh) throws SQLException
      Deprecated.
      in JChem 5.8 Please use DatabaseProperties(ConnectionHandler, boolean) instead. The constructor DatabaseProperties(conh) is equivalent to DatabaseProperties(conh, false).
      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:
      SQLException - if encounter an sql exception
    • DatabaseProperties

      public DatabaseProperties(ConnectionHandler conh, boolean indexTable) throws SQLException
      Constructs an instance for use with JChem structure tables or 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 in case of JChem structure tables.
      Throws:
      SQLException - if encounter an sql exception
      Since:
      JChem 5.0
  • Method Details

    • getPropertyTableName

      public String getPropertyTableName()
      Return the name of the JChem properties table.
      Returns:
      the name of the JChem properties table
      Since:
      JChem 5.12
    • getProperty

      public String getProperty(String name) throws SQLException
      Searches for the property with the specified key in the JChemProperties table. If value is null, returns 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:
      SQLException - if encounter an sql exception
    • getIntProperty

      public int getIntProperty(String name) throws 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.
      Throws:
      NumberFormatException - if the property value cannot be parsed as an integer
      SQLException - if encounter an sql exception
    • addProperty

      public void addProperty(String name, String value) throws SQLException
      Inserts the property with the specified key and value into 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:
      SQLException - if encounter an sql exception
    • updateProperty

      public void updateProperty(String name, String value) throws 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:
      SQLException - if encounter an sql exception
    • setProperty

      public void setProperty(String name, String value) throws 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:
      SQLException - if encounter an sql exception
    • setDuplicateFilteringOption

      public void setDuplicateFilteringOption(String tableName, boolean value) throws SQLException
      Sets the Duplicate filtering table property with the specified value in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted.
      Parameters:
      tableName - Name of the structure table.
      value - The duplicate filtering property value.
      Throws:
      SQLException - if encounter an sql exception
      Since:
      JChem 5.4
    • setAbsoluteStereoOption

      public void setAbsoluteStereoOption(String tableName, boolean value) throws SQLException
      Sets the Absolute stereo table property with the specified value in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted.
      Parameters:
      tableName - Name of the structure table.
      value - The absolute stereo property value.
      Throws:
      SQLException - if encounter an sql exception
    • setTautomerDuplicateFilteringOption

      public void setTautomerDuplicateFilteringOption(String tableName, boolean value) throws SQLException
      Sets the Tautomer duplicate checking table property with the specified value in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted.
      Parameters:
      tableName - Name of the structure table.
      value - The tautomer duplicate checking property value.
      Throws:
      SQLException - if encounter an sql exception
    • setStandardizerConfigOption

      public void setStandardizerConfigOption(String tableName, String value) throws SQLException
      Sets the standardizer configuration table property to the specified value in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted.
      Parameters:
      tableName - Name of the structure table.
      value - The standardizer configuration string.
      Throws:
      SQLException - if encounter an sql exception
    • setTableProperty

      public void setTableProperty(String tableName, String propName, String propValue) throws SQLException
      Sets the given table property in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted.
      Parameters:
      tableName - Name of the structure table.
      propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constans defined in PropertyConstants.Table.
      propValue - the value of the property
      Throws:
      SQLException - if encounter an sql exception
    • getTableProperty

      public String getTableProperty(String tableName, String propName) throws SQLException
      Gets a table property from the JChemProperties table.
      Parameters:
      tableName - Name of the structure table.
      propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constans defined in PropertyConstants.Table.
      Returns:
      The value of table property if it is stored in the JChemProperties table, null otherwise.
      Throws:
      SQLException - if encounter an sql exception
    • getTableIntProperty

      public int getTableIntProperty(String tableName, String propName) throws IllegalArgumentException, NumberFormatException, SQLException
      Gets an integer table property from the JChemProperties table.
      Parameters:
      tableName - Name of the structure table.
      propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constans defined in PropertyConstants.Table.
      Returns:
      The value of table property if it is stored in the JChemProperties table and can be parsed to int.
      Throws:
      IllegalArgumentException - if the given property is not found.
      NumberFormatException - if the given property cannot be parsed to int.
      SQLException - if encounter an sql exception
    • deleteTableProperty

      public void deleteTableProperty(String tableName, String propName) throws SQLException
      Removes a table property from the JChemProperties table.
      Parameters:
      tableName - Name of the structure table.
      propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constans defined in PropertyConstants.Table.
      Throws:
      SQLException - if encounter an sql exception
    • deleteTableProperties

      public void deleteTableProperties(String tableName) throws SQLException
      Removes all table properties related to the given structure table from the JChemProperties table.
      Parameters:
      tableName - Name of the structure table.
      Throws:
      SQLException - if encounter an sql exception
    • setMDTableProperty

      public void setMDTableProperty(String tableName, String descrName, String propName, String propValue) throws SQLException
      Sets the given MD table property in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted.
      Parameters:
      tableName - Name of the structure table.
      descrName - Name of the descriptor.
      propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constans defined in PropertyConstants.Table.
      propValue - the value of the property
      Throws:
      SQLException - if encounter an sql exception
    • getMDTableProperty

      public String getMDTableProperty(String tableName, String descrName, String propName) throws SQLException
      Gets MD table property from the JChemProperties table.
      Parameters:
      tableName - Name of the structure table.
      descrName - Name of the descriptor.
      propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constants defined in PropertyConstants.Table.
      Returns:
      The value of table property if it is stored in the JChemProperties table, null otherwise.
      Throws:
      SQLException - if encounter an sql exception
    • deleteMDTableProperty

      public void deleteMDTableProperty(String tableName, String descrName, String propName) throws SQLException
      Removes MD table property from the JChemProperties table.
      Parameters:
      tableName - Name of the structure table.
      descrName - Name of the descriptor.
      propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constans defined in PropertyConstants.Table.
      Throws:
      SQLException - if encounter an sql exception
    • incrementProperty

      public long incrementProperty(String name) throws 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:
      SQLException - if encounter an sql exception
    • deleteProperty

      public void deleteProperty(String name) throws SQLException
      Removes the row with the specified key from the JChemProperties table, if it exists.
      Parameters:
      name - the property key.
      Throws:
      SQLException - if encounter an sql exception
    • 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
      Returns:
      true if the table exists
    • createPropertyTable

      public static void createPropertyTable(ConnectionHandler conh) throws 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:
      SQLException - if encounter an sql exception
      See Also:
    • createPropertyTable

      public static void createPropertyTable(ConnectionHandler conh, int mySqlTableType) throws 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:
      Throws:
      SQLException - if encounter an sql exception
      See Also:
    • getStructureTableNames

      public Vector<String> getStructureTableNames() throws SQLException
      Returns the names of structure tables registered in the JChemProperties table.
      Returns:
      a vector of all structure table names
      Throws:
      SQLException - if encounter an sql exception
    • getMolecularDescriptors

      public String[] getMolecularDescriptors(String tableName) throws SQLException
      Retrieves the names of MolecularDescriptors assigned to the structure table and stored in the JChem database.
      Parameters:
      tableName - the name of the structure table
      Returns:
      the descriptor names
      Throws:
      SQLException - if encounter an sql exception
    • isMolecularDescriptorDefined

      public boolean isMolecularDescriptorDefined() throws SQLException
      Retrieve whether at least one MolecularDescriptor is defined for any table or not.
      Returns:
      true if at least one descriptor table exists
      Throws:
      SQLException - if encounter an sql exception
    • getMDConfigs

      public String[] getMDConfigs(String tableName, String descriptorName) throws SQLException
      Retrieves the names of stored configurations associated with a certain Molecular Descriptor.
      Doesn't support JChem Cartridge index tables.
      Parameters:
      tableName - the name of the structure table
      descriptorName - the name of the molecular descriptor
      Returns:
      the names of the configurations
      Throws:
      SQLException - if encounter an sql exception
    • getMdProperties

      public Properties getMdProperties(String tableName, String descriptorID) throws SQLException
      Throws:
      SQLException
    • getMolecularDescriptorNames

      public String[] getMolecularDescriptorNames(String tableName) throws SQLException
      Throws:
      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 String[] getChemTermColumns(String tableName) throws 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:
      SQLException - if encounter an sql exception
      Since:
      3.2
    • isChemTermColumnDefined

      public boolean isChemTermColumnDefined() throws SQLException
      Retrieve whether at least one Chemical Term column is defined for any table or not.
      Returns:
      boolean
      Throws:
      SQLException - if encounter an sql exception
    • setChemTermForColumn

      public void setChemTermForColumn(String tableName, String columnName, String expression) throws 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:
      SQLException - if encounter an sql exception
      Since:
      3.2
    • getChemTermForColumn

      public String getChemTermForColumn(String tableName, String columnName) throws 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 of 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:
      SQLException - if encounter an sql exception
      Since:
      3.2
    • deleteChemTermForColumn

      public void deleteChemTermForColumn(String tableName, String columnName) throws 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:
      SQLException - if encounter an sql exception
      Since:
      3.2
    • getTableType

      public int getTableType(String tableName) throws SQLException
      Returns the type of the specified table.
      Parameters:
      tableName - the name of the JChem structure table
      Returns:
      one of the following:
      Throws:
      SQLException - if encounter an sql exception
      Since:
      JChem 3.2
    • setCacheRegistrationTableName

      public String setCacheRegistrationTableName() throws SQLException
      Set the name of the cache registration table for the current property table.
      Returns:
      the newly generated table name.
      Throws:
      SQLException - if encounter an sql exception
    • getCacheRegistrationTableName

      public String getCacheRegistrationTableName() throws SQLException
      Get the cache registration table name of the currently used property table.
      Returns:
      the cache registration table name.
      Throws:
      SQLException - if encounter an sql exception
    • isTautomerDuplicateFilteringEnabled

      public boolean isTautomerDuplicateFilteringEnabled(String tableName) throws 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:
      SQLException - if encounter an sql exception
      Since:
      JChem 5.0
    • getTautomerEqualityMode

      public chemaxon.sss.search.options.TautomerEqualityMode getTautomerEqualityMode(String tableName) throws SQLException
      Throws:
      SQLException
    • isGenericTautomerProtectsChirality

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public boolean isGenericTautomerProtectsChirality(String tableName) throws SQLException
      Deprecated, for removal: This API element is subject to removal in a future version.
      stereo is considered as default in tautomer regions during searching, SearchOptions.setTautomerSearch(int) with value SearchConstants.TAUTOMER_SEARCH_ON_IGNORE_TAUTOMERSTEREO ignores it.
      Returns whether generic tautomer protects chirality in tautomer region.
      Parameters:
      tableName - the name of the JChem structure table
      Returns:
      true if generic tautomer protects chirality
      Throws:
      SQLException - if encounter an sql exception
      Since:
      JChem 5.2.4
    • isSetSwitchOffAllProtectionsForTDF

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public boolean isSetSwitchOffAllProtectionsForTDF(String tableName) throws SQLException
      Deprecated, for removal: This API element is subject to removal in a future version.
      stereo is considered as default in tautomer regions during searching, SearchOptions.setTautomerSearch(int) with value SearchConstants.TAUTOMER_SEARCH_ON_IGNORE_TAUTOMERSTEREO ignores it.
      Returns whether all protections for tautomer duplicate filtering is switched off.
      Parameters:
      tableName - the name of the JChem structure table
      Returns:
      true if all protects are switched off
      Throws:
      SQLException - if encounter an sql exception
      Since:
      JChem 5.5
    • isDatabaseReadonly

      public boolean isDatabaseReadonly() throws SQLException
      Returns whether database of the current JChem property table is readonly.
      Returns:
      true if the database is readonly
      Throws:
      SQLException - if encounter an sql exception
      Since:
      JChem 5.3.2
    • close

      public void close() throws SQLException
      Should be called only if the use of prepared statements are enabled with setUsePreparedStatement(boolean).
      Throws:
      SQLException - if encounter an sql exception
    • getFingerprintParams

      public String[] getFingerprintParams(String tableName) throws SQLException
      Return the fingerprint parameters of a table.
      Parameters:
      tableName - the name of the table
      Returns:
      array that contains 3 elements, the first is the number of bits, the second is the number of ones, the third is the number of edges.
      Throws:
      SQLException - if encounter an sql exception
    • getTableProperties

      public Map<String,String> getTableProperties(String tableName) throws SQLException
      Return all properties for a table.
      Parameters:
      tableName - Name of the structure table
      Returns:
      the property names and values
      Throws:
      SQLException - if encounter an sql exception
    • isDuplicateFilteringOption

      public boolean isDuplicateFilteringOption(String tableName) throws SQLException
      Returns the state of the Duplicate Filtering table option.
      Parameters:
      tableName - Name of the structure table
      Returns:
      the state of the Duplicate Filtering option from the JChem Property Table.
      Throws:
      SQLException - if encounter an sql exception
      Since:
      Jchem 5.4
    • getAllProperties

      public StringBuilder getAllProperties() throws SQLException
      Returns all properties in the JChem property table.
      Returns:
      all property names and values in a formatted StringBuffer
      Throws:
      SQLException - if encounter an sql exception
    • getCacheRegistrationTableName

      public static String getCacheRegistrationTableName(ConnectionHandler conh) throws SQLException
      Get the table name containing the registration information
      Parameters:
      conh - ConnectionHandler to use
      Returns:
      registration table name
      Throws:
      SQLException - if encounter an sql exception
    • getTableNameWithSchema

      public String getTableNameWithSchema(String tableName) throws SQLException
      Throws:
      SQLException
    • getDbmsType

      public int getDbmsType()
    • getCacheUpdaterType

      public chemaxon.jchem.base.storage.cache.CacheUpdaterType getCacheUpdaterType(String tableName) throws SQLException
      Throws:
      SQLException
    • setCacheUpdaterType

      public void setCacheUpdaterType(String tableName, chemaxon.jchem.base.storage.cache.CacheUpdaterType cacheUpdaterType) throws SQLException
      Throws:
      SQLException