Class ConnectionFactory

java.lang.Object
com.softwaremining.sql.ConnectionFactory
Direct Known Subclasses:
ConnectionFactoryImpl

public abstract class ConnectionFactory extends Object
Used by the framework to read db connection url, credentials and various other settings from db.properties file
  • Field Details

    • SCHEMA_NAME

      protected static String SCHEMA_NAME
      defaults to CONNECTION_STRATEGY_SHARE_ESQL_SESSION_CONN
    • REDUCE_GE_OR_EQ

      public static boolean REDUCE_GE_OR_EQ
    • OR_EXPAND_GTEQ_LTEQ

      public static boolean OR_EXPAND_GTEQ_LTEQ
    • OR_EXPAND_GTEQ_SEARCHES__DEFAULT

      public static boolean OR_EXPAND_GTEQ_SEARCHES__DEFAULT
      (default is true) Example: Lets say there are 3 key fields involved in a search with condition GTEQ
      If flag is set to true (default) - then the following SQL condition will be generated
      (A > ? or (A = ? and B > ?) or (A = ? and B = ? and C >= ?))
      With flag is set to FALSE - the following will be generated
      (A >= ?) and (B >= ?) and (C >= ?)
    • OR_CHANGE_GE_CONDITION_TO_LIKE__DEFAULT

      public static boolean OR_CHANGE_GE_CONDITION_TO_LIKE__DEFAULT
      (default is false) The system can replace GE searches to LIKE statements. this can potentially have a huge performance improvement.
      E.g. Consider generating SELECT ... from TABLE WHERE KEY_1 >= ? AND KEY_2 >= ?.
      If each key is 5 chars, and the supplied values are "A " and "B " - the above translates to:
       SELECT ... from TABLE WHERE KEY_1 >= 'A    ' AND KEY_2 >= 'B    '. 

      Converting it to LIKE will become
       SELECT ... from TABLE WHERE KEY_1 LIKE 'A%' AND KEY_2 LIKE 'B%' 

      This makes a significant performance improvements.
    • OR_CHANGE_GTEQ_TO_EQ_FOR_LIKE_CONDITIONS__DEFAULT

      public static boolean OR_CHANGE_GTEQ_TO_EQ_FOR_LIKE_CONDITIONS__DEFAULT
      (default = false) Only applies when OR_CHANGE_GE_CONDITION_TO_LIKE__DEFAULT=true
      E.g. Consider generating SELECT ... from TABLE WHERE KEY_1 >= ? AND KEY_2 >= ?.
      If each key is 5 chars, and the supplied values are "ABCDE" and "B " - the above translates to:
       SELECT ... from TABLE WHERE KEY_1 >= 'ABCDE' AND KEY_2 >= 'B    '. 

      Converting it to LIKE will become
       SELECT ... from TABLE WHERE KEY_1 >= 'ABCDE' AND KEY_2 LIKE 'B%' 

      When this flag is set, if the char-count of a field is equal to that of the supplied value, then the generated SQL will become
       SELECT ... from TABLE WHERE KEY_1 = 'ABCDE' AND KEY_2 LIKE 'B%' 
      This can make a significant improvement to performance .
    • OR_TOP_ROW_SELECT_STRATEGY_COUNT__DEFAULT

      public static int OR_TOP_ROW_SELECT_STRATEGY_COUNT__DEFAULT
      (Default = -1) When set to 0 or 1 , the Object-Relation SQL Generator will produce:
                        SELECT ... FROM table WHERE condition-1 
      When set to greater than 1 - (for Oracle) it will produce:
        SELECT � FROM ( SELECT ... FROM table WHERE condition-1 ) WHERE ROWNUM invalid input: '<' OR_SELECT_TOP_ROW__DEFAULT; 
    • OR_SUPPRESS_SEEKS__DEFAULT

      public static boolean OR_SUPPRESS_SEEKS__DEFAULT
      COBOL Start statement, or CICS STARTBR statement will place the file pointer at the a particular place.
      these statements are translated to the objectRelational."seek" method.
      The next READ statement re-issues the SQL statement, and reads the data. In most cases the Seek statements can be ignored.
    • OR_CLOSE_CONNECTIONS

      public static boolean OR_CLOSE_CONNECTIONS
      Default JDBC connection are not reusable after they are closed, Ie there is no point in pooling them.
      Some connection pooling mechanisms (e.g. Tomcat/JNDI) - create a connections which is effectively a wrappers around JDBC.driver object. In order to recycle such wrappers connections (ie move it into the pool) - a connecion.close() is required.
    • OR_USE_SINGLE_CONNECTION_PER_SESSION

      public static boolean OR_USE_SINGLE_CONNECTION_PER_SESSION
      This is used in BATCH applications with OR files. It allows use of a single connection for all OR classes.
    • FORCE_RESULTSET_TYPE_FORWARD_ONLY

      public static boolean FORCE_RESULTSET_TYPE_FORWARD_ONLY
      Used in SQLWrapper (replacement for KSDS) - forces the JDBC statements to be created with ResultSet.TYPE_FORWARD_ONLY In most cases this does not interfere with "prev" statement of sqlWrapper classes - as they issue SELECT ... where key invalid input: '<' ? (ie in Reverse) and then move forward
    • COMMIT_IMMEDIATELY

      public static boolean COMMIT_IMMEDIATELY
    • DEFAULT_RESULTSET_FETCH_SIZE

      public static int DEFAULT_RESULTSET_FETCH_SIZE
    • DEFAULT_BATCH_SIZE

      public static int DEFAULT_BATCH_SIZE
      used for preparedStatement.addBatch();
    • ESQL_TRIM_INPUT_STRINGS

      public static boolean ESQL_TRIM_INPUT_STRINGS
      This is used in esqlProcessor.setInputParameters( String ...); e.g. when set, it will trim the parameters, e.g. "ABC " will become "ABC". The feature is useful in ORACLE database, but DB2 appears to be performing the trims() automatically,
    • totalRuntime

      public static long totalRuntime
    • propertiesLoaded_auxilaries

      protected static boolean propertiesLoaded_auxilaries
    • RESULTSET_TYPE

      public static int RESULTSET_TYPE
      Used in method ESQLProcessor.prepare( connection.prepareStatement( )
      defaults to ResultSet.TYPE_FORWARD_ONLY (same default used in connection.prepareStatement( ) )
    • RESULTSET_CONCURRENCY

      public static int RESULTSET_CONCURRENCY
      Used in method ESQLProcessor.prepare( connection.prepareStatement( )
      defaults to ResultSet.CONCUR_READ_ONLY (same default used in connection.prepareStatement( ) )
  • Constructor Details

    • ConnectionFactory

      public ConnectionFactory()
  • Method Details

    • getConnection

      public abstract Connection getConnection(String resource, Long sessionId)
      JDBC Connection occasionally times out on Online applications .. user may have left his computer in middle of a transaction
    • getConnection

      public abstract Connection getConnection(Long sessionId)
    • getConnection

      public abstract Connection getConnection(Properties properties, Long sessionId)
    • getConnectionStrategy

      public abstract int getConnectionStrategy(String resourceName)
    • getInstance

      public static ConnectionFactory getInstance()
    • setInstance

      public static void setInstance(ConnectionFactory newInstance)
    • assignDbFeatures

      protected DbFeatures assignDbFeatures(Long sessionId, String databaseVendor)
      dbFeatuers refers to a class representing the underlying database: DB2, Oracle, MySQL , MSSQL , ...
      Parameters:
      properties -
      Returns:
    • getDbFeatures

      public static DbFeatures getDbFeatures(Long sessionId)
    • initializeDbFeatures

      public abstract void initializeDbFeatures(Long sessionId, String dbPropertiesName)
      dbFeatuers refers to a class representing the underlying database: DB2, Oracle, MySQL , MSSQL , ... ALso read all properties - but do not create connection
      Parameters:
      properties -
    • readDefaultDbProperties

      public static void readDefaultDbProperties()
    • loadDbProperties

      public static void loadDbProperties(String dbPropertiesName, Long sessionId)
    • decrypt

      public static String decrypt(String cryptographerClass, String username, String password)
    • setSessionSchemaName

      public static void setSessionSchemaName(Long sessionId, String schemaName)
    • getSchemaName

      public static String getSchemaName(Long sessionId)
    • setSchemaName

      public static void setSchemaName(String schemaName)
    • getDBPropertyFileName

      public static String getDBPropertyFileName(Long sessionId)
    • setDBPropertyFileName

      public static void setDBPropertyFileName(Long sessionId, String dbPropertyFile)