接口 SmartDataSource
- 所有超级接口:
CommonDataSource
,DataSource
,Wrapper
- 所有已知实现类:
SingleConnectionDataSource
public interface SmartDataSource extends DataSource
Extension of thejavax.sql.DataSource
interface, to be implemented by special DataSources that return JDBC Connections in an unwrapped fashion.Classes using this interface can query whether or not the Connection should be closed after an operation. Spring's DataSourceUtils and JdbcTemplate classes automatically perform such a check.
- 作者:
- Rod Johnson, Juergen Hoeller
- 另请参阅:
SingleConnectionDataSource.shouldClose(java.sql.Connection)
,DataSourceUtils.releaseConnection(java.sql.Connection, javax.sql.DataSource)
,JdbcTemplate
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 boolean
shouldClose(Connection con)
Should we close this Connection, obtained from this DataSource?从接口继承的方法 javax.sql.CommonDataSource
createShardingKeyBuilder, getParentLogger
从接口继承的方法 javax.sql.DataSource
createConnectionBuilder, getConnection, getConnection, getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
从接口继承的方法 java.sql.Wrapper
isWrapperFor, unwrap
方法详细资料
shouldClose
boolean shouldClose(Connection con)
Should we close this Connection, obtained from this DataSource?Code that uses Connections from a SmartDataSource should always perform a check via this method before invoking
close()
.Note that the JdbcTemplate class in the 'jdbc.core' package takes care of releasing JDBC Connections, freeing application code of this responsibility.
- 参数:
con
- the Connection to check- 返回:
- whether the given Connection should be closed
- 另请参阅:
Connection.close()