public interface ConnectionProvider
| 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.
|
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() |
boolean acceptsUrl(@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props)
protocol - 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 connectionboolean acceptsStrategy(@NonNull HostRole role, @NonNull java.lang.String strategy)
role - determines if the connection provider should return a reader host or a writer
hoststrategy - the selection strategy to useHostSpec 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
UnsupportedOperationException if the specified strategy is unsupported.hosts - 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 providerjava.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
protocol - 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 occursjava.lang.String getTargetName()