|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.webmethods.portal.service.sql.core.ConnectionManager
public class ConnectionManager
ConnectionManager manages connection pools for each of the sql data sources registered with the portal.
Typically, the only method from this class that a portlet developer would need to use would be the
ConnectionManager.getConnInfo(java.lang.String)
method that returns the information needed to establish a connection
to a registered sql datasource.
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
,
DataManager
Constructor Summary | |
---|---|
ConnectionManager()
Default Constructor needed for reflection. |
Method Summary | |
---|---|
protected static void |
addDatasource(ConnectionInfo connInfo)
Adds new datasource. |
protected static IConnectionProvider |
createConnProvider(ConnectionInfo connInfo)
Creates and caches connection provider for a given connection info |
static ConnectionInfo |
getConnInfo(String datasourceName)
Returns ConnectionInfo for given datasource name. |
static IConnectionProvider |
getConnProvider(String datasourceName)
Returns connection provider implementation instance for the given datasource name. |
static Collection |
getConnProviders()
Returns list of all registered IConnectionProvider implementations. |
static List |
getDatasources()
Returns list of all registered data sources. |
static void |
init()
Called automatically by the portal runtime to initialize the ConnectionMangager. |
static void |
init(Element config)
Called automatically by the portal runtime to initialize the ConnectionMangager. |
void |
init(IComponentData data,
String phase)
Called automatically by the portal runtime to initialize the ConnectionMangager. |
static void |
init(String serverType,
String hostName,
String database,
String user,
String password)
Initializes ConnectionManager when not part of the PortalSystem. |
protected static void |
persistConfigFile(Document configDoc,
boolean makeBackup)
This will persist the database config file. |
static void |
postInit()
Called automatically by the portal runtime to initialize the ConnectionMangager. |
static void |
registerDatasource(String datasourceName,
String serverType,
String hostName,
String database,
String user,
String password)
|
static void |
registerNewDatasource(ConnectionInfo connInfo)
Registers new sql datasource and persists the updated configuration. |
static void |
registerNewDatasource(ConnectionInfo connInfo,
boolean persist)
Registers new sql datasource and persists the updated configuration. |
protected static ConnectionInfo |
replaceSAGProxyDriversWithMWS(ConnectionInfo connInfo)
|
static void |
saveConfig()
Persists the database configuration into Registry. |
void |
shutdown()
Called automatically by the portal runtime when the VM is closing down. |
static void |
testConnection(ConnectionInfo connInfo)
Tests opening a connection to the given datasource. |
static void |
unregisterDatasource(String datasourceName)
Unregisters the datasource by given name and persists the updated configuration. |
static void |
updateDatasource(String origName,
ConnectionInfo connInfo)
Updates existing datasource and persists the updated configuration. |
protected static void |
validateDatasource()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String CONNECTION_CONFIG_NAME
public static final String CONFIG_BAK_EXTENSION
public static String ORACLE_THIN_URL_TEMPLATE
public static String ORACLE_THIN_DRIVER
public static String ORACLE_THIN_URL_PARSER_EXPRESSION
public static final String SAG_BASE_PROXY_DRIVER_PATH
public static final String ORACLE_SAG_PROXY_DRIVER
public static final String MSSQL_SAG_PROXY_DRIVER
public static final String DB2_SAG_PROXY_DRIVER
public static final String INFORMIX_SAG_PROXY_DRIVER
public static final String SYBASE_SAG_PROXY_DRIVER
public static final String MYSQL_SAG_PROXY_DRIVER
public static final String DRIVER_PARAMETER
public static String ORACLE_URL_TEMPLATE
public static String ORACLE_DRIVER
public static String ORACLE_URL_PARSER_EXPRESSION
public static String MSSQL_URL_TEMPLATE
public static String MSSQL_DRIVER
public static String MSSQL_URL_PARSER_EXPRESSION
public static String DB2_URL_TEMPLATE
public static String DB2_DRIVER
public static String DB2_URL_PARSER_EXPRESSION
public static String INFORMIX_URL_TEMPLATE
public static String INFORMIX_DRIVER
public static String INFORMIX_URL_PARSER_EXPRESSION
public static String SYBASE_URL_TEMPLATE
public static String SYBASE_DRIVER
public static String SYBASE_URL_PARSER_EXPRESSION
public static String DERBY_URL_TEMPLATE
public static String DERBY_DRIVER
public static String DERBY_URL_PARSER_EXPRESSION
public static String DERBY_SERVER_URL_PARSER_EXPRESSION
public static String MYSQL_URL_TEMPLATE
public static String MYSQL_DRIVER
public static String MYSQL_URL_PARSER_EXPRESSION
public static String MYSQL_SERVER_URL_PARSER_EXPRESSION
public static String SERVER_ORACLE
public static String SERVER_MSSQL
public static String SERVER_DERBY
public static String SERVER_DB2
protected static final String CONNECTION_NODE_QUERY
protected static Document m_rootConfig
protected static Collection m_connProviderList
protected static HashMap m_connProviderMap
protected static HashMap m_connInfoMap
protected static ConnectionInfo m_defConnInfo
Constructor Detail |
---|
public ConnectionManager()
Method Detail |
---|
public static void init(String serverType, String hostName, String database, String user, String password) throws Exception
serverType
- ISqlWorker
server typehostName
- database host and port. For example myserver:1521database
- database name. For Oracle database this is a SIDuser
- password
-
PortalException
Exception
public void init(IComponentData data, String phase) throws InitializationException
data
- the IComponentData
contains the configuration data for the registered data sources.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() throws InitializationException
InitializationException
public static void postInit() throws InitializationException
Initializes connection info service information. This needs to be done after the MetadataSystem has initialized.
InitializationException
public static void init(Element config) throws InitializationException
Initializes ConnectionManager from an XML configuration element
InitializationException
public static IConnectionProvider getConnProvider(String datasourceName)
datasourceName
- the datasource name to retrive the IConnectionProvider
instance for
public static ConnectionInfo getConnInfo(String datasourceName)
ConnectionInfo
for given datasource name. A typical portal
developer would call this method to retrieve the connection information needed
to open a connection to a registered sql datasource.
datasourceName
- the datasource name to retrive the ConnectionInfo
for
ConnectionInfo
instance for the given datasourceNamepublic static List getDatasources()
List
will
be ConnectionInfo
objects. A typical portal developer would rarely need to
call this method.
List
of the currently registered sql datasourcespublic static Collection getConnProviders()
IConnectionProvider
implementations.
The contents of the List
will be IConnectionProvider
objects.
A typical portal developer would rarely need to call this method.
Collection
of currently registered connection providerspublic static void saveConfig() throws MetaException
MetaException
public static void registerDatasource(String datasourceName, String serverType, String hostName, String database, String user, String password) throws MetaException
MetaException
public static void unregisterDatasource(String datasourceName) throws MetaException
dsnname
- the name of the datasource to unregister
MetaException
public static void registerNewDatasource(ConnectionInfo connInfo) throws MetaException
connInfo
- the connection info for the new datasource
MetaException
public static void registerNewDatasource(ConnectionInfo connInfo, boolean persist) throws MetaException
connInfo
- the connection info for the new datasourcepersist
- whether new configuration should be persisted back to the config file
MetaException
protected static ConnectionInfo replaceSAGProxyDriversWithMWS(ConnectionInfo connInfo)
public static void updateDatasource(String origName, ConnectionInfo connInfo) throws MetaException
origName
- the name of the datasource that is being updatedconnInfo
- the new connection info for datasource
MetaException
public static void testConnection(ConnectionInfo connInfo) throws MetaException
connInfo
- the ConnectionInfo
instance for the datasource to test
MetaException
- if there was an error testing the connection.protected static void addDatasource(ConnectionInfo connInfo)
protected static void validateDatasource() throws InitializationException
InitializationException
protected static void persistConfigFile(Document configDoc, boolean makeBackup) throws IOException
configDoc
- the XML Document containing all the configuration information for
the current directory servicesmakeBackup
- is whether or not to create a backup before storing the config
IOException
protected static IConnectionProvider createConnProvider(ConnectionInfo connInfo)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |