public class C3P0PooledConnectionProvider extends java.lang.Object implements PooledConnectionProvider, CanReleaseResources
| Modifier and Type | Field and Description |
|---|---|
protected static java.util.Map<java.lang.String,HostSelector> |
acceptedStrategies |
protected static SlidingExpirationCache<java.lang.String,com.mchange.v2.c3p0.ComboPooledDataSource> |
databasePools |
protected static long |
poolExpirationCheckNanos |
| Constructor and Description |
|---|
C3P0PooledConnectionProvider() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsStrategy(@NonNull HostRole role,
@NonNull java.lang.String strategy)
Indicates whether the selection strategy is supported by the connection provider.
|
boolean |
acceptsUrl(@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props)
Indicates whether this ConnectionProvider can provide connections for the given host and
properties.
|
java.sql.Connection |
connect(@NonNull java.lang.String protocol,
@NonNull Dialect dialect,
@NonNull TargetDriverDialect targetDriverDialect,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props)
Called once per connection that needs to be created.
|
protected com.mchange.v2.c3p0.ComboPooledDataSource |
createDataSource(@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props,
TargetDriverDialect driverDialect) |
HostSpec |
getHostSpecByStrategy(@NonNull java.util.List<HostSpec> hosts,
@NonNull HostRole role,
@NonNull java.lang.String strategy,
@Nullable java.util.Properties props)
Return a reader or a writer node using the specified strategy.
|
java.lang.String |
getTargetName() |
void |
releaseResources()
An object that implements this interface should release all acquired resources assuming it may
be disposed at any time.
|
protected static final SlidingExpirationCache<java.lang.String,com.mchange.v2.c3p0.ComboPooledDataSource> databasePools
protected static final java.util.Map<java.lang.String,HostSelector> acceptedStrategies
protected static final long poolExpirationCheckNanos
public boolean acceptsUrl(@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props)
ConnectionProvideracceptsUrl in interface ConnectionProviderprotocol - the connection protocol (example "jdbc:mysql://")hostSpec - the HostSpec containing the host-port information for the host to connect toprops - the Properties to use for the connectionpublic boolean acceptsStrategy(@NonNull HostRole role, @NonNull java.lang.String strategy)
ConnectionProvideracceptsStrategy in interface ConnectionProviderrole - determines if the connection provider should return a reader host or a writer
hoststrategy - the selection strategy to usepublic HostSpec getHostSpecByStrategy(@NonNull java.util.List<HostSpec> hosts, @NonNull HostRole role, @NonNull java.lang.String strategy, @Nullable java.util.Properties props) throws java.sql.SQLException, java.lang.UnsupportedOperationException
ConnectionProviderUnsupportedOperationException if the specified strategy is unsupported.getHostSpecByStrategy in interface ConnectionProviderhosts - the list of HostSpec to select fromrole - determines if the connection provider should return a writer or a readerstrategy - the strategy determining how the HostSpec should be selected, e.g.,
random or round-robinprops - any properties that are required by the provided strategy to select a hostHostSpec selected using the specified strategyjava.sql.SQLException - if an error occurred while returning the hostsjava.lang.UnsupportedOperationException - if the strategy is unsupported by the providerpublic java.sql.Connection connect(@NonNull java.lang.String protocol,
@NonNull Dialect dialect,
@NonNull TargetDriverDialect targetDriverDialect,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props)
throws java.sql.SQLException
ConnectionProviderconnect in interface ConnectionProviderprotocol - the connection protocol (example "jdbc:mysql://")dialect - the database dialecttargetDriverDialect - the target driver dialecthostSpec - the HostSpec containing the host-port information for the host to connect toprops - the Properties to use for the connectionConnection resulting from the given connection informationjava.sql.SQLException - if an error occursprotected com.mchange.v2.c3p0.ComboPooledDataSource createDataSource(@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props,
TargetDriverDialect driverDialect)
public java.lang.String getTargetName()
getTargetName in interface ConnectionProviderpublic void releaseResources()
CanReleaseResourcesCalling this method does NOT mean that an object is disposing and there won't be any further calls. An object should keep its functional state after calling this method.
releaseResources in interface CanReleaseResources