|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.webmethods.portal.service.sql.DataManager
public class DataManager
DataManager works as a factory class to create SqlWorker instances.
Here is an example of opening a connection to a sql datasource:
String dataSource = "dataSourceName"; ISqlWorker worker = null; try { // get the connection information for the datasource ConnectionInfo conninfo = ConnectionManager.getConnInfo(dataSource); //get a worker instance from the data manager worker = DataManager.createWorker(dataSource); //TODO use one of the execute methods from the worker to // perform the query or update } catch (SQLException e) { //log and report the exception Debug.fatal(e, m_logCategory); throw new PortalException(e); } finally { if (worker != null) { //release the worker so the sql resources can be reclaimed worker.release(); } }
ISqlWorker
,
ConnectionManager
Field Summary | |
---|---|
static String |
DATA_SERVICE
|
static String |
DATA_SERVICE_ALIAS_PREFIX
|
static String |
DATA_SERVICE_FOLDER
|
static boolean |
DEBUG_ON
Switch for internal SQL debug logging |
static Category |
logCategory
Log4J category for SqlOutput |
static Object |
perf_Database_Exec
perfstat objects |
static Object |
perf_Get_Conn
perfstat objects |
static String |
THREAD_LOCAL_TRANSACTION
Thread local key for SQL transaction |
Constructor Summary | |
---|---|
DataManager()
|
Method Summary | |
---|---|
static void |
beginTran()
Starts sql transaction for default database connection on the current thread. |
static void |
commitTran()
Commits any outstanding transaction on the current thread. |
static ISqlWorker |
createSafeWorker(String datasourceName)
Get worker object to perform some database work. |
static ISqlWorker |
createWorker()
Get worker object to perform some database work for the default portal datasource. |
static ISqlWorker |
createWorker(String datasourceName)
Get worker object to perform some database work |
protected static void |
executeSqlScriptDsn(Reader script,
com.webmethods.portal.service.sql.DataManager.ScriptExecuteContext context)
Executes SQL script from passed reader against specified DSN |
static void |
executeSqlScriptFile(String fileName)
|
static void |
executeSqlScriptFile(String fileName,
PrintStream terminalWriter,
PrintStream spoolWriter,
boolean ignoreErrors,
Map args)
|
static void |
executeSqlScriptString(String script,
String datasource)
Execute Sql script file against default DSN |
static void |
executeSqlScriptString(String script,
String datasource,
boolean ignoreErrors,
Map args)
Execute Sql script file against default DSN |
static Connection |
getConnection()
Returns connection to a default database |
static Connection |
getConnection(String datasource)
Returns connection to a specific datasource |
static IDatabaseRuntime |
getDatabaseRuntime()
Returns current database runtime which is setup for active portal database connection |
static int |
getDefaultServerType()
Returns name of the default database server type: mssql, oracle, mysql |
static void |
init()
Called automatically by the portal runtime to initialize the DataMangager. |
void |
init(IComponentData data,
String phase)
Called automatically by the portal runtime to initialize the DataMangager. |
static boolean |
isInitialized()
Check to see if the DataManger has been initialized. |
static void |
release()
Release all connection resources |
static void |
releaseConnection(Connection conn)
Releases connection back to the pool |
static void |
rollbackTran()
Rollsback any outstanding transaction on the current thread. |
void |
shutdown()
Called automatically by the portal runtime when the VM is closing down. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DATA_SERVICE
public static final String DATA_SERVICE_FOLDER
public static final String DATA_SERVICE_ALIAS_PREFIX
public static final String THREAD_LOCAL_TRANSACTION
public static Category logCategory
public static boolean DEBUG_ON
public static Object perf_Database_Exec
public static Object perf_Get_Conn
Constructor Detail |
---|
public DataManager()
Method Detail |
---|
public void init(IComponentData data, String phase) throws InitializationException
data
- the IComponentData
contains the configuration data for the data manager.phase
- the name of the startup phase that is currently executing
com.webmethods.portal.system.init.InitializationException
InitializationException
IInitializable
public void shutdown()
IInitializable
public static void init()
public static boolean isInitialized()
public static int getDefaultServerType()
ISqlWorker.SERVERTYPE_ORACLE
for oracle or ISqlWorker.SERVERTYPE_MSSQL
otherwisepublic static ISqlWorker createWorker() throws SQLException
SQLException
public static void beginTran() throws SQLException
ISqlWorker.beginTran()
method.
SQLException
public static void commitTran() throws SQLException
ISqlWorker.commitTran()
method
SQLException
public static void rollbackTran() throws SQLException
ISqlWorker.rollbackTran()
method
SQLException
public static ISqlWorker createWorker(String datasourceName) throws SQLException
datasourceName
- name of the datasource to create a worker for
SQLException
public static ISqlWorker createSafeWorker(String datasourceName) throws SQLException
datasourceName
- name of the datasource to use
SQLException
public static IDatabaseRuntime getDatabaseRuntime()
public static Connection getConnection()
public static Connection getConnection(String datasource)
datasource
- name of the datasourcepublic static void release()
public static void releaseConnection(Connection conn)
public static void executeSqlScriptFile(String fileName) throws SQLException, ServerBusyException, DeadlockException
SQLException
ServerBusyException
DeadlockException
public static void executeSqlScriptFile(String fileName, PrintStream terminalWriter, PrintStream spoolWriter, boolean ignoreErrors, Map args) throws SQLException, ServerBusyException, DeadlockException
SQLException
ServerBusyException
DeadlockException
public static void executeSqlScriptString(String script, String datasource) throws SQLException, ServerBusyException, DeadlockException
SQLException
ServerBusyException
DeadlockException
public static void executeSqlScriptString(String script, String datasource, boolean ignoreErrors, Map args) throws SQLException, ServerBusyException, DeadlockException
SQLException
ServerBusyException
DeadlockException
protected static void executeSqlScriptDsn(Reader script, com.webmethods.portal.service.sql.DataManager.ScriptExecuteContext context) throws SQLException, ServerBusyException, DeadlockException
SQLException
ServerBusyException
DeadlockException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |