public abstract class AbstractRoutingDataSource extends java.lang.Object implements RoutingDataSource, javax.sql.DataSource, java.io.Closeable
限定符和类型 | 字段和说明 |
---|---|
protected javax.sql.DataSource |
defaultTargetDataSource |
protected boolean |
strict
严格模式(启用后在未匹配到指定数据源时候会抛出异常,不启用则使用默认数据源.)
|
protected java.util.Map<java.lang.String,javax.sql.DataSource> |
targetDataSources |
构造器和说明 |
---|
AbstractRoutingDataSource() |
限定符和类型 | 方法和说明 |
---|---|
void |
close() |
protected void |
closeDataSource(javax.sql.DataSource ds)
尝试关闭数据源
|
abstract java.lang.String |
determineCurrentKey()
确定当前数据源键
|
javax.sql.DataSource |
determineCurrentTarget()
确定当前目标数据源
|
java.sql.Connection |
getConnection() |
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password) |
int |
getLoginTimeout() |
java.io.PrintWriter |
getLogWriter() |
java.util.logging.Logger |
getParentLogger() |
boolean |
isWrapperFor(java.lang.Class<?> iface) |
void |
setDefaultTargetDataSource(javax.sql.DataSource defaultTargetDataSource)
设置默认目标数据源
|
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(java.io.PrintWriter out) |
void |
setStrict(boolean strict)
设置严格模式
|
void |
setTargetDataSources(java.util.Map<java.lang.String,javax.sql.DataSource> targetDataSources)
设置目标数据源集合(替换掉旧的)
|
<T> T |
unwrap(java.lang.Class<T> iface) |
protected javax.sql.DataSource defaultTargetDataSource
protected java.util.Map<java.lang.String,javax.sql.DataSource> targetDataSources
protected boolean strict
public void setTargetDataSources(java.util.Map<java.lang.String,javax.sql.DataSource> targetDataSources)
public void setDefaultTargetDataSource(javax.sql.DataSource defaultTargetDataSource)
public void setStrict(boolean strict)
public abstract java.lang.String determineCurrentKey()
public javax.sql.DataSource determineCurrentTarget()
determineCurrentTarget
在接口中 RoutingDataSource
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
在接口中 javax.sql.DataSource
java.sql.SQLException
public java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLException
getConnection
在接口中 javax.sql.DataSource
java.sql.SQLException
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
unwrap
在接口中 java.sql.Wrapper
java.sql.SQLException
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
isWrapperFor
在接口中 java.sql.Wrapper
java.sql.SQLException
public java.io.PrintWriter getLogWriter() throws java.sql.SQLException
getLogWriter
在接口中 javax.sql.CommonDataSource
java.sql.SQLException
public void setLogWriter(java.io.PrintWriter out) throws java.sql.SQLException
setLogWriter
在接口中 javax.sql.CommonDataSource
java.sql.SQLException
public void setLoginTimeout(int seconds) throws java.sql.SQLException
setLoginTimeout
在接口中 javax.sql.CommonDataSource
java.sql.SQLException
public int getLoginTimeout() throws java.sql.SQLException
getLoginTimeout
在接口中 javax.sql.CommonDataSource
java.sql.SQLException
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
getParentLogger
在接口中 javax.sql.CommonDataSource
java.sql.SQLFeatureNotSupportedException
public void close() throws java.io.IOException
close
在接口中 java.io.Closeable
close
在接口中 java.lang.AutoCloseable
java.io.IOException
protected void closeDataSource(javax.sql.DataSource ds) throws java.io.IOException
java.io.IOException