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 DataSource
SQLException
public Connection getConnection(String userName, String password) throws SQLException
getConnection
in interface DataSource
SQLException
public PrintWriter getLogWriter() throws SQLException
getLogWriter
in interface CommonDataSource
SQLException
public void setLogWriter(PrintWriter printWriter) throws SQLException
setLogWriter
in interface CommonDataSource
SQLException
public void setLoginTimeout(int loginTimeout) throws SQLException
setLoginTimeout
in interface CommonDataSource
SQLException
public int getLoginTimeout() throws SQLException
getLoginTimeout
in interface CommonDataSource
SQLException
public <T> T unwrap(Class<T> iface) throws SQLException
unwrap
in interface Wrapper
SQLException
public boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor
in interface Wrapper
SQLException
public Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger
in interface CommonDataSource
SQLFeatureNotSupportedException
protected void initDataSource() throws SQLException
SQLException
protected void setProperty(Object instance, String key, String value) throws InvocationTargetException, IllegalAccessException
Copyright © 2010-2014 The Apache Software Foundation. All Rights Reserved.