Package org.ametys.core.datasource
Class ConnectionHelper
java.lang.Object
org.ametys.core.datasource.ConnectionHelper
- All Implemented Interfaces:
 Disposable,Component,Serviceable
Helper component used to retrieve java.sql.Connection from pools
- 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringID of database extension for Derbystatic final StringID of database extension for Hsqldbstatic final StringID of database extension for Mysqlstatic final StringID of database extension for Oraclestatic final StringID of database extension for Postgresstatic final StringID of database extension for Unknownstatic final StringThe Avalon role - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic voidcleanup(Connection con) Commit and closes a java.sql.Connectionstatic voidCloses a java.sql.ResultSetstatic voidCloses a java.sql.Statementvoiddispose()static ConnectiongetConnection(String id) Returns a Connection from the pool.static StringgetDatabaseType(String jdbcURL) Determine the database typestatic StringgetDatabaseType(Connection connection) Determine the database typeReturns the SQLAbstractDataSourceManager.DataSourceDefinitioncorresponding to the given id.static ConnectionGet a connection to the internal sql data sourcevoidservice(ServiceManager serviceManager)  
- 
Field Details
- 
ROLE
The Avalon role - 
DATABASE_UNKNOWN
ID of database extension for Unknown- See Also:
 
 - 
DATABASE_MYSQL
ID of database extension for Mysql- See Also:
 
 - 
DATABASE_ORACLE
ID of database extension for Oracle- See Also:
 
 - 
DATABASE_POSTGRES
ID of database extension for Postgres- See Also:
 
 - 
DATABASE_DERBY
ID of database extension for Derby- See Also:
 
 - 
DATABASE_HSQLDB
ID of database extension for Hsqldb- See Also:
 
 
 - 
 - 
Constructor Details
- 
ConnectionHelper
public ConnectionHelper() 
 - 
 - 
Method Details
- 
service
- Specified by:
 servicein interfaceServiceable- Throws:
 ServiceException
 - 
dispose
- Specified by:
 disposein interfaceDisposable
 - 
getInternalSQLDataSourceConnection
Get a connection to the internal sql data source- Returns:
 - java.sql.Connection to query the internal SQL database
 
 - 
getConnection
Returns a Connection from the pool.- Parameters:
 id- the id of the data source- Returns:
 - a java.sql.Connection to query a SQL database
 
 - 
cleanup
Commit and closes a java.sql.Connection- Parameters:
 con- the Connection to close
 - 
cleanup
Closes a java.sql.Statement- Parameters:
 stmt- the Statement to close
 - 
cleanup
Closes a java.sql.ResultSet- Parameters:
 rs- the ResultSet to close
 - 
getDatabaseType
Determine the database type- Parameters:
 connection- The jdbc connection to the database- Returns:
 - The database type id or empty string if unknown
 
 - 
getDatabaseType
Determine the database type- Parameters:
 jdbcURL- The jdbc url used to connect to the database- Returns:
 - The database type id or null if unknown
 
 - 
getDataSourceDefinition
Returns the SQLAbstractDataSourceManager.DataSourceDefinitioncorresponding to the given id.- Parameters:
 id- the id of the data source- Returns:
 - the 
AbstractDataSourceManager.DataSourceDefinition. 
 
 -