Package com.softwaremining.sql
Class ConnectionFactory
java.lang.Object
com.softwaremining.sql.ConnectionFactory
- Direct Known Subclasses:
ConnectionFactoryImpl
Used by the framework to read db connection url, credentials and various other settings from db.properties file
-
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
static int
used for preparedStatement.addBatch();static int
static boolean
This is used in esqlProcessor.setInputParameters( String ...); e.g.static boolean
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 ...static boolean
(default is false) The system can replace GE searches to LIKE statements.static boolean
(default = false) Only applies when OR_CHANGE_GE_CONDITION_TO_LIKE__DEFAULT=true
E.g.static boolean
Default JDBC connection are not reusable after they are closed, Ie there is no point in pooling them.static boolean
static boolean
(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 >= ?)static boolean
COBOL Start statement, or CICS STARTBR statement will place the file pointer at the a particular place.static int
(Default = -1) When set to 0 or 1 , the Object-Relation SQL Generator will produce:static boolean
This is used in BATCH applications with OR files.protected static boolean
static boolean
static int
Used in method ESQLProcessor.prepare( connection.prepareStatement( )
defaults to ResultSet.CONCUR_READ_ONLY (same default used in connection.prepareStatement( ) )static int
Used in method ESQLProcessor.prepare( connection.prepareStatement( )
defaults to ResultSet.TYPE_FORWARD_ONLY (same default used in connection.prepareStatement( ) )protected static String
defaults to CONNECTION_STRATEGY_SHARE_ESQL_SESSION_CONNstatic long
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected DbFeatures
assignDbFeatures
(Long sessionId, String databaseVendor) dbFeatuers refers to a class representing the underlying database: DB2, Oracle, MySQL , MSSQL , ...static String
abstract Connection
getConnection
(Long sessionId) abstract Connection
getConnection
(String resource, Long sessionId) JDBC Connection occasionally times out on Online applications ..abstract Connection
getConnection
(Properties properties, Long sessionId) abstract int
getConnectionStrategy
(String resourceName) static DbFeatures
getDbFeatures
(Long sessionId) static String
getDBPropertyFileName
(Long sessionId) static ConnectionFactory
static String
getSchemaName
(Long sessionId) abstract void
initializeDbFeatures
(Long sessionId, String dbPropertiesName) dbFeatuers refers to a class representing the underlying database: DB2, Oracle, MySQL , MSSQL , ...static void
loadDbProperties
(String dbPropertiesName, Long sessionId) static void
static void
setDBPropertyFileName
(Long sessionId, String dbPropertyFile) static void
setInstance
(ConnectionFactory newInstance) static void
setSchemaName
(String schemaName) static void
setSessionSchemaName
(Long sessionId, String schemaName)
-
Field Details
-
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 becomeSELECT ... 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 becomeSELECT ... 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 becomeSELECT ... 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__DEFAULTCOBOL 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_CONNECTIONSDefault 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_SESSIONThis 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_ONLYUsed 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_SIZEused for preparedStatement.addBatch(); -
ESQL_TRIM_INPUT_STRINGS
public static boolean ESQL_TRIM_INPUT_STRINGSThis 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_TYPEUsed in method ESQLProcessor.prepare( connection.prepareStatement( )
defaults to ResultSet.TYPE_FORWARD_ONLY (same default used in connection.prepareStatement( ) ) -
RESULTSET_CONCURRENCY
public static int RESULTSET_CONCURRENCYUsed 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
JDBC Connection occasionally times out on Online applications .. user may have left his computer in middle of a transaction -
getConnection
-
getConnection
-
getConnectionStrategy
-
getInstance
-
setInstance
-
assignDbFeatures
dbFeatuers refers to a class representing the underlying database: DB2, Oracle, MySQL , MSSQL , ...- Parameters:
properties
-- Returns:
-
getDbFeatures
-
initializeDbFeatures
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
-
decrypt
-
setSessionSchemaName
-
getSchemaName
-
setSchemaName
-
getDBPropertyFileName
-
setDBPropertyFileName
-