public class ConfigurableDataSource extends Object implements DataSource
This class can be used instead of a real DataSource. It is a simple wrapper to hide any database configuration details and make it configurable via CDI.
See DataSourceConfig on how to configure it!
The configuration itself will be provided via CDI mechanics.
To distinguish different databases, users can specify a
connectionId. If no connectionId is set,
the String default will be used
| Constructor and Description |
|---|
ConfigurableDataSource() |
| Modifier and Type | Method and Description |
|---|---|
Connection |
getConnection() |
Connection |
getConnection(String userName,
String password) |
int |
getLoginTimeout() |
PrintWriter |
getLogWriter() |
Logger |
getParentLogger()
NEW JDK1.7 signature.
|
protected void |
initDataSource()
Initialize the DataSource either from JNDI or via JDBC Driver.
|
boolean |
isWrapperFor(Class<?> iface) |
void |
setConnectionId(String connectionId) |
void |
setLoginTimeout(int loginTimeout) |
void |
setLogWriter(PrintWriter printWriter) |
protected void |
setProperty(Object instance,
String key,
String value) |
<T> T |
unwrap(Class<T> iface) |
public void setConnectionId(String connectionId)
public Connection getConnection() throws SQLException
getConnection in interface DataSourceSQLExceptionpublic Connection getConnection(String userName, String password) throws SQLException
getConnection in interface DataSourceSQLExceptionpublic PrintWriter getLogWriter() throws SQLException
getLogWriter in interface CommonDataSourceSQLExceptionpublic void setLogWriter(PrintWriter printWriter) throws SQLException
setLogWriter in interface CommonDataSourceSQLExceptionpublic void setLoginTimeout(int loginTimeout)
throws SQLException
setLoginTimeout in interface CommonDataSourceSQLExceptionpublic int getLoginTimeout()
throws SQLException
getLoginTimeout in interface CommonDataSourceSQLExceptionpublic <T> T unwrap(Class<T> iface) throws SQLException
unwrap in interface WrapperSQLExceptionpublic boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor in interface WrapperSQLExceptionpublic Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger in interface CommonDataSourceSQLFeatureNotSupportedExceptionprotected void initDataSource()
throws SQLException
SQLExceptionprotected void setProperty(Object instance, String key, String value) throws InvocationTargetException, IllegalAccessException
Copyright © 2010-2014 The Apache Software Foundation. All Rights Reserved.