Class ConnectionFactory
java.lang.Object
org.apache.jackrabbit.core.util.db.ConnectionFactory
A factory for new database connections.
Supported are regular JDBC drivers, as well as
JNDI resources.
FIXME: the registry currently is ClassLoader wide. I.e., if you start two repositories
then you share the registered datasources...
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()getDataBaseType(String logicalName) getDataSource(String logicalName) Retrieves a configured data source by logical name.getDataSource(String driver, String url, String user, String password) Retrieve aDataSourcefor the specified properties.voidRegisters a number of data sources.static Connectionunwrap(Connection con) Needed for pre-10R2 Oracle blob support....:( This method actually assumes that we are using commons DBCP 1.2.2.
-
Constructor Details
-
ConnectionFactory
public ConnectionFactory()
-
-
Method Details
-
registerDataSources
Registers a number of data sources.- Parameters:
dsc- theDataSourceConfigwhich contains the configuration- Throws:
RepositoryException
-
getDataSource
Retrieves a configured data source by logical name.- Parameters:
logicalName- the name of theDataSource- Returns:
- a
DataSource - Throws:
RepositoryException- if there is noDataSourcewith the given name
-
getDataBaseType
- Parameters:
logicalName- the name of theDataSource- Returns:
- the configured database type
- Throws:
RepositoryException- if there is noDataSourcewith the given name
-
getDataSource
public DataSource getDataSource(String driver, String url, String user, String password) throws RepositoryException, SQLException Retrieve aDataSourcefor the specified properties. This can be a JNDI Data Source as well. To do that, the driver class name must reference ajavax.naming.Contextclass (for examplejavax.naming.InitialContext), and the URL must be the JNDI URL (for examplejava:comp/env/jdbc/Test).- Parameters:
driver- the JDBC driver or the Context classurl- the database URLuser- the user namepassword- the password- Returns:
- the
DataSource - Throws:
RepositoryException- if the driver could not be loadedSQLException- if the connection could not be established
-
close
public void close() -
unwrap
Needed for pre-10R2 Oracle blob support....:( This method actually assumes that we are using commons DBCP 1.2.2.- Parameters:
con- the commons-DBCPDelegatingConnectionto unwrap- Returns:
- the unwrapped connection
- Throws:
SQLException
-