Implementation of {@link SmartDataSource} that wraps a single JDBC Connectionwhich is not closed after use. Obviously, this is not multi-threading capable.
Note that at shutdown, someone should close the underlying Connection via the close()
method. Client code will never call close on the Connection handle if it is SmartDataSource-aware (e.g. uses DataSourceUtils.releaseConnection
).
If client code will call close()
in the assumption of a pooled Connection, like when using persistence tools, set "suppressClose" to "true". This will return a close-suppressing proxy instead of the physical Connection. Be aware that you will not be able to cast this to a native OracleConnection
or the like anymore; you need to use a {@link org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor} then.
This is primarily intended for testing. For example, it enables easy testing outside an application server, for code that expects to work on a DataSource. In contrast to {@link DriverManagerDataSource}, it reuses the same Connection all the time, avoiding excessive creation of physical Connections.
@author Rod Johnson
@author Juergen Hoeller
@see #getConnection()
@see java.sql.Connection#close()
@see DataSourceUtils#releaseConnection
@see org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor