Package com.mysql.cj.jdbc.ha
Class LoadBalancedMySQLConnection
java.lang.Object
com.mysql.cj.jdbc.ha.MultiHostMySQLConnection
com.mysql.cj.jdbc.ha.LoadBalancedMySQLConnection
- All Implemented Interfaces:
LoadBalancedConnection
,JdbcConnection
,MysqlConnection
,TransactionEventHandler
,java.lang.AutoCloseable
,java.sql.Connection
,java.sql.Wrapper
public class LoadBalancedMySQLConnection extends MultiHostMySQLConnection implements LoadBalancedConnection
-
Field Summary
-
Constructor Summary
Constructors Constructor Description LoadBalancedMySQLConnection(LoadBalancedConnectionProxy proxy)
-
Method Summary
Modifier and Type Method Description boolean
addHost(java.lang.String host)
void
close()
LoadBalancedConnectionProxy
getThisAsProxy()
boolean
isWrapperFor(java.lang.Class<?> iface)
void
ping()
Detect if the connection is still good by sending a ping command to the server.void
ping(boolean allConnections)
void
removeHost(java.lang.String host)
void
removeHostWhenNotInUse(java.lang.String host)
<T> T
unwrap(java.lang.Class<T> iface)
Methods inherited from class com.mysql.cj.jdbc.ha.MultiHostMySQLConnection
abort, abortInternal, changeUser, checkClosed, cleanup, clearHasTriedMaster, clearWarnings, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, commit, createArrayOf, createBlob, createClob, createNClob, createNewIO, createSQLXML, createStatement, createStatement, createStatement, createStruct, decachePreparedStatement, getActiveMySQLConnection, getActiveStatementCount, getAutoCommit, getAutoIncrementIncrement, getCachedMetaData, getCatalog, getCharacterSetMetadata, getClientInfo, getClientInfo, getClientInfoProviderImpl, getConnectionMutex, getDatabase, getExceptionInterceptor, getHoldability, getHost, getHostPortPair, getId, getIdleFor, getMetaData, getMetadataSafeStatement, getMultiHostParentProxy, getMultiHostSafeProxy, getNetworkTimeout, getProperties, getPropertySet, getQueryInterceptorsInstances, getSchema, getServerVersion, getSession, getSessionMaxRows, getStatementComment, getTransactionIsolation, getTypeMap, getURL, getUser, getWarnings, hasSameProperties, hasTriedMaster, initializeResultsMetadataFromCache, initializeSafeQueryInterceptors, isClosed, isInGlobalTx, isProxySet, isReadOnly, isReadOnly, isSameResource, isServerLocal, isSourceConnection, isValid, lowerCaseTableNames, nativeSQL, normalClose, pingInternal, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, realClose, recachePreparedStatement, registerStatement, releaseSavepoint, resetServerState, rollback, rollback, serverPrepareStatement, serverPrepareStatement, serverPrepareStatement, serverPrepareStatement, serverPrepareStatement, serverPrepareStatement, setAutoCommit, setCatalog, setClientInfo, setClientInfo, setDatabase, setFailedOver, setHoldability, setInGlobalTx, setNetworkTimeout, setProxy, setReadOnly, setReadOnlyInternal, setSavepoint, setSavepoint, setSchema, setSessionMaxRows, setStatementComment, setTransactionIsolation, setTypeMap, shutdownServer, storesLowerCaseTableName, throwConnectionClosedException, transactionBegun, transactionCompleted, unregisterStatement, unSafeQueryInterceptors
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.sql.Connection
abort, beginRequest, clearWarnings, commit, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, endRequest, getAutoCommit, getCatalog, getClientInfo, getClientInfo, getHoldability, getMetaData, getNetworkTimeout, getSchema, getTransactionIsolation, getTypeMap, getWarnings, isClosed, isReadOnly, isValid, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setClientInfo, setClientInfo, setHoldability, setNetworkTimeout, setReadOnly, setSavepoint, setSavepoint, setSchema, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid, setTransactionIsolation, setTypeMap
Methods inherited from interface com.mysql.cj.jdbc.JdbcConnection
abortInternal, changeUser, clearHasTriedMaster, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, decachePreparedStatement, getActiveMySQLConnection, getActiveStatementCount, getAutoIncrementIncrement, getCachedMetaData, getCharacterSetMetadata, getClientInfoProviderImpl, getDatabase, getHost, getHostPortPair, getIdleFor, getMetadataSafeStatement, getMultiHostParentProxy, getMultiHostSafeProxy, getPropertySet, getQueryInterceptorsInstances, getServerVersion, getSessionMaxRows, getStatementComment, hasSameProperties, hasTriedMaster, initializeResultsMetadataFromCache, initializeSafeQueryInterceptors, isInGlobalTx, isMasterConnection, isProxySet, isReadOnly, isSameResource, isServerLocal, isSourceConnection, lowerCaseTableNames, pingInternal, realClose, recachePreparedStatement, registerStatement, resetServerState, serverPrepareStatement, serverPrepareStatement, serverPrepareStatement, serverPrepareStatement, serverPrepareStatement, serverPrepareStatement, setDatabase, setFailedOver, setInGlobalTx, setProxy, setReadOnlyInternal, setSessionMaxRows, setStatementComment, shutdownServer, storesLowerCaseTableName, throwConnectionClosedException, unregisterStatement, unSafeQueryInterceptors
Methods inherited from interface com.mysql.cj.MysqlConnection
checkClosed, cleanup, createNewIO, getConnectionMutex, getExceptionInterceptor, getId, getProperties, getSession, getURL, getUser, normalClose
Methods inherited from interface com.mysql.cj.TransactionEventHandler
transactionBegun, transactionCompleted
-
Constructor Details
-
Method Details
-
getThisAsProxy
- Overrides:
getThisAsProxy
in classMultiHostMySQLConnection
-
close
public void close() throws java.sql.SQLException- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.sql.Connection
- Overrides:
close
in classMultiHostMySQLConnection
- Throws:
java.sql.SQLException
-
ping
public void ping() throws java.sql.SQLExceptionDescription copied from interface:JdbcConnection
Detect if the connection is still good by sending a ping command to the server.- Specified by:
ping
in interfaceJdbcConnection
- Overrides:
ping
in classMultiHostMySQLConnection
- Throws:
java.sql.SQLException
- if the ping fails
-
ping
public void ping(boolean allConnections) throws java.sql.SQLException- Specified by:
ping
in interfaceLoadBalancedConnection
- Throws:
java.sql.SQLException
-
addHost
public boolean addHost(java.lang.String host) throws java.sql.SQLException- Specified by:
addHost
in interfaceLoadBalancedConnection
- Throws:
java.sql.SQLException
-
removeHost
public void removeHost(java.lang.String host) throws java.sql.SQLException- Specified by:
removeHost
in interfaceLoadBalancedConnection
- Throws:
java.sql.SQLException
-
removeHostWhenNotInUse
public void removeHostWhenNotInUse(java.lang.String host) throws java.sql.SQLException- Specified by:
removeHostWhenNotInUse
in interfaceLoadBalancedConnection
- Throws:
java.sql.SQLException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException- Specified by:
isWrapperFor
in interfacejava.sql.Wrapper
- Overrides:
isWrapperFor
in classMultiHostMySQLConnection
- Throws:
java.sql.SQLException
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException- Specified by:
unwrap
in interfacejava.sql.Wrapper
- Overrides:
unwrap
in classMultiHostMySQLConnection
- Throws:
java.sql.SQLException
-