public class SingleConnectionDataSource extends Object implements Closeable
getConnection() is called.
Note that closing the connection you got using getConnection() will make it available again. If it is not
closed, calling getConnection() will throw an IllegalStateException.
To actually close the connection, call close() on this DataSource.
Instances of this class are thread-safe, but the connections returned when calling getConnection() aren't.| Constructor and Description |
|---|
SingleConnectionDataSource(Connection connection)
Creates a single single connection datasource.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
Connection |
getConnection() |
Connection |
getConnection(String username,
String password)
Parameters passed to this method are ignored, this is equivalent to calling
DataSource.getConnection() directly. |
int |
getLoginTimeout() |
PrintWriter |
getLogWriter() |
Logger |
getParentLogger() |
boolean |
isWrapperFor(Class<?> iface) |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(PrintWriter out) |
<T> T |
unwrap(Class<T> iface) |
public SingleConnectionDataSource(Connection connection)
connection - the underlying jdbc connection to usepublic Connection getConnection() throws SQLException
getConnection in interface DataSourceSQLExceptionpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic Connection getConnection(String username, String password) throws SQLException
DataSource.getConnection() directly.getConnection in interface DataSourceSQLExceptionpublic <T> T unwrap(Class<T> iface) throws SQLException
unwrap in interface WrapperSQLExceptionpublic boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor in interface WrapperSQLExceptionpublic PrintWriter getLogWriter() throws SQLException
getLogWriter in interface CommonDataSourceSQLExceptionpublic void setLogWriter(PrintWriter out) throws SQLException
setLogWriter in interface CommonDataSourceSQLExceptionpublic void setLoginTimeout(int seconds)
throws SQLException
setLoginTimeout in interface CommonDataSourceSQLExceptionpublic int getLoginTimeout()
throws SQLException
getLoginTimeout in interface CommonDataSourceSQLExceptionpublic Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger in interface CommonDataSourceSQLFeatureNotSupportedExceptionCopyright © 2019. All rights reserved.