public final class UnpooledConnectionProvider
extends java.lang.Object
implements org.hibernate.service.jdbc.connections.spi.ConnectionProvider, org.hibernate.service.spi.Configurable
ConnectionProvider
interface which does no connection pooling, but instead fetches a new JDBC
connection each time getConnection()
is invoked, and closes that
connection each time closeConnection(java.sql.Connection)
is invoked.
This implementation is used for in-memory databases, when connection pooling actually works slower than opening a new connection each time. Also it can be used for debugging purposes, it allows one to debug connection-related issues while avoiding the behavioral side effects which occur when a pooling connection provider recycles, proxies, caches, or otherwise obfuscates JDBC connections.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
jdbcURL
URL to connect to the backing datastore
|
private static java.util.logging.Logger |
LOG
Logger
|
private java.lang.String |
password
Password used to connect
|
private java.lang.String |
user
User name used to connect
|
Constructor and Description |
---|
UnpooledConnectionProvider()
Default constructor required by Hibernate's connection provider
contract.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
No-op implementation of required method.
|
void |
closeConnection(java.sql.Connection conn)
Close the given JDBC connection.
|
void |
configure(java.util.Map props)
Configure connection provider, extracting a URL, user name, and
password from the specified properties.
|
java.sql.Connection |
getConnection()
Obtain a new JDBC connection from the backing datastore.
|
boolean |
isUnwrappableAs(java.lang.Class unwrapType)
Allows to determine if this wrapped service can be unwrapped as the indicated type.
|
boolean |
supportsAggressiveRelease()
Returns
false to indicate JDBC connections will not be
released aggressively. |
<T> T |
unwrap(java.lang.Class<T> unwrapType)
Unproxy the service proxy.
|
private static final java.util.logging.Logger LOG
private java.lang.String jdbcURL
private java.lang.String user
private java.lang.String password
public UnpooledConnectionProvider()
public void configure(java.util.Map props)
configure
in interface org.hibernate.service.spi.Configurable
props
- Hibernate configuration properties.public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface org.hibernate.service.jdbc.connections.spi.ConnectionProvider
java.sql.SQLException
public void closeConnection(java.sql.Connection conn) throws java.sql.SQLException
closeConnection
in interface org.hibernate.service.jdbc.connections.spi.ConnectionProvider
conn
- Connection to close.java.sql.SQLException
public void close()
public boolean supportsAggressiveRelease()
false
to indicate JDBC connections will not be
released aggressively.supportsAggressiveRelease
in interface org.hibernate.service.jdbc.connections.spi.ConnectionProvider
false
.public boolean isUnwrappableAs(java.lang.Class unwrapType)
isUnwrappableAs
in interface org.hibernate.service.spi.Wrapped
unwrapType
- The type to check.true
if this wrapped service can be unwrapped as the indicated type.public <T> T unwrap(java.lang.Class<T> unwrapType)
unwrap
in interface org.hibernate.service.spi.Wrapped
unwrapType
- The java type as which to unwrap this instance.org.hibernate.service.UnknownUnwrapTypeException
- if the service cannot be unwrapped as the indicated type.