Package com.ibm.di.store
Class StoreFactory
- java.lang.Object
-
- com.ibm.di.store.StoreFactory
-
public class StoreFactory extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_PROPERTYSTOREstatic java.lang.StringJDBC_DRIVER_DB2static java.lang.StringJDBC_DRIVER_DERBY_EMBstatic java.lang.StringJDBC_DRIVER_DERBY_NETstatic java.lang.StringJDBC_DRIVER_MSSQLstatic java.lang.StringJDBC_DRIVER_ORACLEstatic java.lang.StringJDBC_DRIVER_SOLIDstatic java.lang.StringREGEXstatic java.lang.StringSOLUTION_DIRstatic java.lang.StringVARCHAR_LENGTH
-
Constructor Summary
Constructors Constructor Description StoreFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddebugmsg(java.lang.String msg)static java.lang.ObjectdeserializeObject(java.lang.Object o)Deserializes a byte array into a Java object.static java.lang.ObjectdeserializeObjectFromBytes(byte[] bytes)static java.lang.ExceptiondropTable(java.lang.String tableName)Drops a table in the default database.static booleandropTable(java.sql.Connection connection, java.lang.String table)Drops a table in the database associated with connection.static java.sql.ConnectiongetConnection()Returns a connection object to the default database.static java.sql.ConnectiongetConnection(boolean autoCommit)Returns a connection object to the default database using the default username/password.static java.sql.ConnectiongetConnection(java.lang.String database)Returns a connection object to the named database with AutoCommit set to TRUE using the default username/password.static java.sql.ConnectiongetConnection(java.lang.String database, boolean autoCommit)Returns a connection object to the named database with the default username/password.static java.sql.ConnectiongetConnection(java.lang.String database, boolean autoCommit, java.lang.String user, java.lang.String password, java.util.Properties info)Returns a connection to the named database.static java.lang.StringgetDbHost()static java.lang.StringgetDbPort()static java.lang.StringgetDefaultDatabase()static PropertyStoregetDefaultPropertyStore()Returns the default property store.static DeltaStoregetDeltaStore(java.lang.String identifier, boolean isRestarting)Returns the DeltaStore with identifierstatic java.lang.StringgetJdbcDriver()static java.lang.StringgetJdbcPassword()static java.lang.StringgetJdbcURL()static java.lang.StringgetJdbcUser()static java.lang.StringgetProperty(java.lang.String key)This method will look at the configuration in the caller's thread (RS.getServer) to see if it overrides the default settings from global/solution properties.static PropertyStoregetPropertyStore(java.lang.String name)Returns the PropertyStore identified by name.static java.lang.StringgetSysStoreCreateStmtByDriver(java.lang.String driver)This method returns the proper 'CREATE TABLE' statement for the System Store Connector based on the specified JDBC driver name.static java.lang.StringgetSystemDatabase()Returns the default system database namestatic java.lang.StringgetSystemDatabaseURL()Returns the SystemStore JDBC URL.static java.util.Vector<java.lang.String>getTables(java.sql.Connection connection, java.lang.String table)static java.lang.StringgetVarcharLength()static booleanisDerbyDriver(java.lang.String driver)static booleanisDerbyNetworkDriver(java.lang.String driver)Determines if the passed driver is a Derby Network Driver.static booleanisMSSQLDriver(java.lang.String driver)static voidlogmsg(java.lang.String msg)static voidreleaseDB(java.lang.String id)static voidretainDB(java.lang.String id, java.lang.String db)static byte[]serializeObject(java.lang.Object obj)Serializes an object to a byte array.static voidsetDerbyUserPassword(java.lang.String user, java.lang.String password)static voidshutdown()Shuts down all open databases.static voidstartDerbyServer(java.lang.String hostname, java.lang.String portNo, boolean sysIBM)Start the networked Derby Server.static voidstopDerbyServer(java.lang.String hostname, int port)static booleantableExists(java.sql.Connection connection, java.lang.String table)Checks if a table is accessible in the database.static booleanverifyTable(java.sql.Connection connection, java.lang.String table, java.util.Vector<java.lang.String> sql)Verifies that a table is accessible in the database.
-
-
-
Field Detail
-
JDBC_DRIVER_DERBY_NET
public static final java.lang.String JDBC_DRIVER_DERBY_NET
- See Also:
- Constant Field Values
-
JDBC_DRIVER_DERBY_EMB
public static final java.lang.String JDBC_DRIVER_DERBY_EMB
- See Also:
- Constant Field Values
-
JDBC_DRIVER_DB2
public static final java.lang.String JDBC_DRIVER_DB2
- See Also:
- Constant Field Values
-
JDBC_DRIVER_ORACLE
public static final java.lang.String JDBC_DRIVER_ORACLE
- See Also:
- Constant Field Values
-
JDBC_DRIVER_MSSQL
public static final java.lang.String JDBC_DRIVER_MSSQL
- See Also:
- Constant Field Values
-
JDBC_DRIVER_SOLID
public static final java.lang.String JDBC_DRIVER_SOLID
- See Also:
- Constant Field Values
-
DEFAULT_PROPERTYSTORE
public static final java.lang.String DEFAULT_PROPERTYSTORE
- See Also:
- Constant Field Values
-
REGEX
public static final java.lang.String REGEX
- See Also:
- Constant Field Values
-
VARCHAR_LENGTH
public static final java.lang.String VARCHAR_LENGTH
-
SOLUTION_DIR
public static final java.lang.String SOLUTION_DIR
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDefaultPropertyStore
public static PropertyStore getDefaultPropertyStore() throws java.lang.Exception
Returns the default property store.- Throws:
java.lang.Exception
-
getPropertyStore
public static PropertyStore getPropertyStore(java.lang.String name) throws java.lang.Exception
Returns the PropertyStore identified by name. Only one instance of a given name is present at one time.- Parameters:
name- The property store name- Returns:
- The property store object associated with name
- Throws:
java.lang.Exception
-
getDeltaStore
public static DeltaStore getDeltaStore(java.lang.String identifier, boolean isRestarting) throws java.lang.Exception
Returns the DeltaStore with identifier- Parameters:
identifier- The delta table identity/tablenameisRestarting- True if the delta is opened in restart mode- Returns:
- The DeltaStore object associated with identifier
- Throws:
java.lang.Exception
-
getSystemDatabaseURL
public static java.lang.String getSystemDatabaseURL()
Returns the SystemStore JDBC URL.
-
getSystemDatabase
public static java.lang.String getSystemDatabase()
Returns the default system database name
-
getConnection
public static java.sql.Connection getConnection() throws java.lang.ExceptionReturns a connection object to the default database. The connection object is in auto-commit mode and uses the default username/password.- Returns:
- A connection object to the named database.
- Throws:
java.lang.Exception
-
getConnection
public static java.sql.Connection getConnection(boolean autoCommit) throws java.lang.ExceptionReturns a connection object to the default database using the default username/password.- Parameters:
autoCommit- The auto-commit flag- Returns:
- A connection object to the named database.
- Throws:
java.lang.Exception
-
getConnection
public static java.sql.Connection getConnection(java.lang.String database) throws java.lang.ExceptionReturns a connection object to the named database with AutoCommit set to TRUE using the default username/password.- Parameters:
database- The database name- Returns:
- A connection object to the named database.
- Throws:
java.lang.Exception
-
getConnection
public static java.sql.Connection getConnection(java.lang.String database, boolean autoCommit) throws java.lang.ExceptionReturns a connection object to the named database with the default username/password.- Parameters:
database- The database nameautoCommit- The auto-commit flag- Returns:
- A connection object to the named database.
- Throws:
java.lang.Exception
-
getConnection
public static java.sql.Connection getConnection(java.lang.String database, boolean autoCommit, java.lang.String user, java.lang.String password, java.util.Properties info) throws java.lang.ExceptionReturns a connection to the named database.- Parameters:
database- If the value starts with "jdbc:" then it is used asis to obtain a connection object. Otherwise, this method prepends the JDBC_URL setting from the global.properties file and appends ";create=true". When prepending JDBC_URL it is assumed that Derby is used.autoCommit- The auto commit flag set on the connection objectuser- The usernamepassword- The passwordinfo- If specified, this method will use the database asis (e.g. no prepend/append) combined with this parameter to obtain a connection object. The info object should contain fields for user and pass and other related parameters to the driver.- Throws:
java.lang.Exception
-
setDerbyUserPassword
public static void setDerbyUserPassword(java.lang.String user, java.lang.String password)
-
dropTable
public static boolean dropTable(java.sql.Connection connection, java.lang.String table)Drops a table in the database associated with connection.- Parameters:
connection- The connection object obtained by getConnection()table- The table to drop
-
verifyTable
public static boolean verifyTable(java.sql.Connection connection, java.lang.String table, java.util.Vector<java.lang.String> sql) throws java.lang.ExceptionVerifies that a table is accessible in the database.- Parameters:
connection- The connection object obtained by getConnection(). If NULL, a connection to the default table is obtained.table- The table name to verifysql- A vector of SQL statements to create the table if it does not exist- Throws:
java.lang.Exception
-
tableExists
public static boolean tableExists(java.sql.Connection connection, java.lang.String table) throws java.lang.ExceptionChecks if a table is accessible in the database.- Parameters:
connection- The connection object obtained by getConnection(). If NULL, a connection to the default table is obtained.table- The table name to verify- Throws:
java.lang.Exception
-
getTables
public static java.util.Vector<java.lang.String> getTables(java.sql.Connection connection, java.lang.String table) throws java.lang.Exception- Throws:
java.lang.Exception
-
shutdown
public static void shutdown()
Shuts down all open databases.
-
dropTable
public static java.lang.Exception dropTable(java.lang.String tableName)
Drops a table in the default database.- Parameters:
tableName- The name of the table to drop.
-
serializeObject
public static byte[] serializeObject(java.lang.Object obj) throws java.lang.ExceptionSerializes an object to a byte array.- Parameters:
obj- The object to serialize- Returns:
- The byte array containing the serialized object
- Throws:
java.lang.Exception
-
deserializeObject
public static java.lang.Object deserializeObject(java.lang.Object o) throws java.lang.ExceptionDeserializes a byte array into a Java object.- Parameters:
o- The byte array with the serialized Java object- Returns:
- The resurrected java object
- Throws:
java.lang.Exception
-
deserializeObjectFromBytes
public static java.lang.Object deserializeObjectFromBytes(byte[] bytes) throws java.lang.Exception- Throws:
java.lang.Exception
-
retainDB
public static void retainDB(java.lang.String id, java.lang.String db)
-
releaseDB
public static void releaseDB(java.lang.String id)
-
logmsg
public static void logmsg(java.lang.String msg)
-
debugmsg
public static void debugmsg(java.lang.String msg)
-
startDerbyServer
public static void startDerbyServer(java.lang.String hostname, java.lang.String portNo, boolean sysIBM) throws java.lang.ExceptionStart the networked Derby Server. This method does not use the API, but spawns a new process, to let the database stay around after exiting the server/CE.- Parameters:
hostname-portNo-sysIBM-- Throws:
java.lang.Exception
-
stopDerbyServer
public static void stopDerbyServer(java.lang.String hostname, int port) throws java.lang.Exception- Throws:
java.lang.Exception
-
isDerbyNetworkDriver
public static boolean isDerbyNetworkDriver(java.lang.String driver)
Determines if the passed driver is a Derby Network Driver.- Returns:
- true if the passed driver is a Derby network driver otherwise false.
-
isDerbyDriver
public static boolean isDerbyDriver(java.lang.String driver)
-
isMSSQLDriver
public static boolean isMSSQLDriver(java.lang.String driver)
-
getDefaultDatabase
public static java.lang.String getDefaultDatabase()
-
getJdbcDriver
public static java.lang.String getJdbcDriver()
-
getJdbcURL
public static java.lang.String getJdbcURL()
-
getJdbcUser
public static java.lang.String getJdbcUser()
-
getJdbcPassword
public static java.lang.String getJdbcPassword()
-
getVarcharLength
public static java.lang.String getVarcharLength()
-
getDbHost
public static java.lang.String getDbHost()
-
getDbPort
public static java.lang.String getDbPort()
-
getSysStoreCreateStmtByDriver
public static java.lang.String getSysStoreCreateStmtByDriver(java.lang.String driver)
This method returns the proper 'CREATE TABLE' statement for the System Store Connector based on the specified JDBC driver name.- Parameters:
driver- java class name of the JDBC driver- Returns:
- the proper 'CREATE TABLE' statement for the used database;
nullif the driver is not recognized.
-
getProperty
public static java.lang.String getProperty(java.lang.String key)
This method will look at the configuration in the caller's thread (RS.getServer) to see if it overrides the default settings from global/solution properties. If the custom system store settings are enabled the value is retrieved from the configuration, otherwise it is retrieved by System.getProperty().- Parameters:
key- the property's indentifier- Returns:
- the value corresponding to the specified identifier.
-
-