public final class ConnectionHelper extends Object implements Component, Serviceable, Disposable
Modifier and Type | Field and Description |
---|---|
private static Logger |
_logger
Logger for traces
|
private static ServiceManager |
_manager |
private static SQLDataSourceManager |
_sqlDataSourceManager
The manager for SQL data source
|
static String |
DATABASE_DERBY
ID of database extension for Derby
|
static String |
DATABASE_HSQLDB
ID of database extension for Hsqldb
|
static String |
DATABASE_MYSQL
ID of database extension for Mysql
|
static String |
DATABASE_ORACLE
ID of database extension for Oracle
|
static String |
DATABASE_POSTGRES
ID of database extension for Postgres
|
static String |
DATABASE_UNKNOWN
ID of database extension for Unknown
|
static String |
ROLE
The Avalon role
|
Constructor and Description |
---|
ConnectionHelper() |
Modifier and Type | Method and Description |
---|---|
static void |
cleanup(Connection con)
Commit and closes a java.sql.Connection
|
static void |
cleanup(ResultSet rs)
Closes a java.sql.ResultSet
|
static void |
cleanup(Statement stmt)
Closes a java.sql.Statement
|
void |
dispose() |
static Connection |
getConnection(String id)
Returns a Connection from the pool.
|
static String |
getDatabaseType(Connection connection)
Determine the database type
|
static String |
getDatabaseType(String jdbcURL)
Determine the database type
|
static AbstractDataSourceManager.DataSourceDefinition |
getDataSourceDefinition(String id)
Returns the SQL
AbstractDataSourceManager.DataSourceDefinition corresponding to the given id. |
static Connection |
getInternalSQLDataSourceConnection()
Get a connection to the internal sql data source
|
private static SQLDataSourceManager |
getSQLDataSourceManager() |
void |
service(ServiceManager serviceManager) |
public static final String DATABASE_UNKNOWN
public static final String DATABASE_MYSQL
public static final String DATABASE_ORACLE
public static final String DATABASE_POSTGRES
public static final String DATABASE_DERBY
public static final String DATABASE_HSQLDB
private static SQLDataSourceManager _sqlDataSourceManager
private static ServiceManager _manager
public ConnectionHelper()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
ServiceException
public void dispose()
dispose
in interface Disposable
private static SQLDataSourceManager getSQLDataSourceManager()
public static Connection getInternalSQLDataSourceConnection()
public static Connection getConnection(String id)
id
- the id of the data sourcepublic static void cleanup(Connection con)
con
- the Connection to closepublic static void cleanup(Statement stmt)
stmt
- the Statement to closepublic static void cleanup(ResultSet rs)
rs
- the ResultSet to closepublic static String getDatabaseType(Connection connection)
connection
- The jdbc connection to the databasepublic static String getDatabaseType(String jdbcURL)
jdbcURL
- The jdbc url used to connect to the databasepublic static AbstractDataSourceManager.DataSourceDefinition getDataSourceDefinition(String id)
AbstractDataSourceManager.DataSourceDefinition
corresponding to the given id.id
- the id of the data sourceAbstractDataSourceManager.DataSourceDefinition
.