Package com.mysql.cj.jdbc.ha
Class ReplicationMySQLConnection
java.lang.Object
com.mysql.cj.jdbc.ha.MultiHostMySQLConnection
com.mysql.cj.jdbc.ha.ReplicationMySQLConnection
- All Implemented Interfaces:
ReplicationConnection,JdbcConnection,MysqlConnection,TransactionEventHandler,java.lang.AutoCloseable,java.sql.Connection,java.sql.Wrapper
public class ReplicationMySQLConnection extends MultiHostMySQLConnection implements ReplicationConnection
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ReplicationMySQLConnection(MultiHostConnectionProxy proxy) -
Method Summary
Modifier and Type Method Description voidabort(java.util.concurrent.Executor executor)voidabortInternal()Clobbers the physical network connection and marks this connection as closed.voidaddReplicaHost(java.lang.String host)voidchangeUser(java.lang.String userName, java.lang.String newPassword)Changes the user on this connection by performing a re-authentication.voidclearHasTriedMaster()Deprecated.JdbcConnectiongetActiveMySQLConnection()longgetConnectionGroupId()JdbcConnectiongetCurrentConnection()java.util.PropertiesgetProperties()Returns the parsed and passed in properties for this connection.JdbcConnectiongetReplicaConnection()JdbcConnectiongetSourceConnection()ReplicationConnectionProxygetThisAsProxy()booleanhasSameProperties(JdbcConnection c)Does this connection have the same properties as another?booleanisHostReplica(java.lang.String host)booleanisHostSource(java.lang.String host)booleanisReadOnly()booleanisWrapperFor(java.lang.Class<?> iface)voidping()Detect if the connection is still good by sending a ping command to the server.voidpromoteReplicaToSource(java.lang.String host)voidremoveReplica(java.lang.String host)voidremoveReplica(java.lang.String host, boolean closeGently)voidremoveSourceHost(java.lang.String host)voidremoveSourceHost(java.lang.String host, boolean waitUntilNotInUse)voidsetProxy(JdbcConnection proxy)voidsetReadOnly(boolean readOnlyFlag)voidsetStatementComment(java.lang.String comment)Sets the comment that will be prepended to all statements sent to the server.<T> Tunwrap(java.lang.Class<T> iface)Methods inherited from class com.mysql.cj.jdbc.ha.MultiHostMySQLConnection
checkClosed, cleanup, clearWarnings, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, close, commit, createArrayOf, createBlob, createClob, createNClob, createNewIO, createSQLXML, createStatement, createStatement, createStatement, createStruct, decachePreparedStatement, getActiveStatementCount, getAutoCommit, getAutoIncrementIncrement, getCachedMetaData, getCatalog, getCharacterSetMetadata, getClientInfo, getClientInfo, getClientInfoProviderImpl, getConnectionMutex, getDatabase, getExceptionInterceptor, getHoldability, getHost, getHostPortPair, getId, getIdleFor, getMetaData, getMetadataSafeStatement, getMultiHostParentProxy, getMultiHostSafeProxy, getNetworkTimeout, getPropertySet, getQueryInterceptorsInstances, getSchema, getServerVersion, getSession, getSessionMaxRows, getStatementComment, getTransactionIsolation, getTypeMap, getURL, getUser, getWarnings, hasTriedMaster, initializeResultsMetadataFromCache, initializeSafeQueryInterceptors, isClosed, isInGlobalTx, isProxySet, 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, setReadOnlyInternal, setSavepoint, setSavepoint, setSchema, setSessionMaxRows, setTransactionIsolation, setTypeMap, shutdownServer, storesLowerCaseTableName, throwConnectionClosedException, transactionBegun, transactionCompleted, unregisterStatement, unSafeQueryInterceptorsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.sql.Connection
beginRequest, clearWarnings, close, commit, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, endRequest, getAutoCommit, getCatalog, getClientInfo, getClientInfo, getHoldability, getMetaData, getNetworkTimeout, getSchema, getTransactionIsolation, getTypeMap, getWarnings, isClosed, isValid, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setClientInfo, setClientInfo, setHoldability, setNetworkTimeout, setSavepoint, setSavepoint, setSchema, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid, setTransactionIsolation, setTypeMapMethods inherited from interface com.mysql.cj.jdbc.JdbcConnection
clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, clientPrepareStatement, decachePreparedStatement, getActiveStatementCount, getAutoIncrementIncrement, getCachedMetaData, getCharacterSetMetadata, getClientInfoProviderImpl, getDatabase, getHost, getHostPortPair, getIdleFor, getMetadataSafeStatement, getMultiHostParentProxy, getMultiHostSafeProxy, getPropertySet, getQueryInterceptorsInstances, getServerVersion, getSessionMaxRows, getStatementComment, 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, setReadOnlyInternal, setSessionMaxRows, shutdownServer, storesLowerCaseTableName, throwConnectionClosedException, unregisterStatement, unSafeQueryInterceptorsMethods inherited from interface com.mysql.cj.MysqlConnection
checkClosed, cleanup, createNewIO, getConnectionMutex, getExceptionInterceptor, getId, getSession, getURL, getUser, normalCloseMethods inherited from interface com.mysql.cj.jdbc.ha.ReplicationConnection
addSlaveHost, getMasterConnection, getSlavesConnection, isHostMaster, isHostSlave, promoteSlaveToMaster, removeMasterHost, removeMasterHost, removeSlave, removeSlaveMethods inherited from interface com.mysql.cj.TransactionEventHandler
transactionBegun, transactionCompleted
-
Constructor Details
-
Method Details
-
getThisAsProxy
- Overrides:
getThisAsProxyin classMultiHostMySQLConnection
-
getActiveMySQLConnection
- Specified by:
getActiveMySQLConnectionin interfaceJdbcConnection- Overrides:
getActiveMySQLConnectionin classMultiHostMySQLConnection
-
getCurrentConnection
- Specified by:
getCurrentConnectionin interfaceReplicationConnection
-
getConnectionGroupId
public long getConnectionGroupId()- Specified by:
getConnectionGroupIdin interfaceReplicationConnection
-
getSourceConnection
- Specified by:
getSourceConnectionin interfaceReplicationConnection
-
promoteReplicaToSource
public void promoteReplicaToSource(java.lang.String host) throws java.sql.SQLException- Specified by:
promoteReplicaToSourcein interfaceReplicationConnection- Throws:
java.sql.SQLException
-
removeSourceHost
public void removeSourceHost(java.lang.String host) throws java.sql.SQLException- Specified by:
removeSourceHostin interfaceReplicationConnection- Throws:
java.sql.SQLException
-
removeSourceHost
public void removeSourceHost(java.lang.String host, boolean waitUntilNotInUse) throws java.sql.SQLException- Specified by:
removeSourceHostin interfaceReplicationConnection- Throws:
java.sql.SQLException
-
isHostSource
public boolean isHostSource(java.lang.String host)- Specified by:
isHostSourcein interfaceReplicationConnection
-
getReplicaConnection
- Specified by:
getReplicaConnectionin interfaceReplicationConnection
-
addReplicaHost
public void addReplicaHost(java.lang.String host) throws java.sql.SQLException- Specified by:
addReplicaHostin interfaceReplicationConnection- Throws:
java.sql.SQLException
-
removeReplica
public void removeReplica(java.lang.String host) throws java.sql.SQLException- Specified by:
removeReplicain interfaceReplicationConnection- Throws:
java.sql.SQLException
-
removeReplica
public void removeReplica(java.lang.String host, boolean closeGently) throws java.sql.SQLException- Specified by:
removeReplicain interfaceReplicationConnection- Throws:
java.sql.SQLException
-
isHostReplica
public boolean isHostReplica(java.lang.String host)- Specified by:
isHostReplicain interfaceReplicationConnection
-
setReadOnly
public void setReadOnly(boolean readOnlyFlag) throws java.sql.SQLException- Specified by:
setReadOnlyin interfacejava.sql.Connection- Overrides:
setReadOnlyin classMultiHostMySQLConnection- Throws:
java.sql.SQLException
-
isReadOnly
public boolean isReadOnly() throws java.sql.SQLException- Specified by:
isReadOnlyin interfacejava.sql.Connection- Overrides:
isReadOnlyin classMultiHostMySQLConnection- Throws:
java.sql.SQLException
-
ping
public void ping() throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionDetect if the connection is still good by sending a ping command to the server.- Specified by:
pingin interfaceJdbcConnection- Overrides:
pingin classMultiHostMySQLConnection- Throws:
java.sql.SQLException- if the ping fails
-
changeUser
public void changeUser(java.lang.String userName, java.lang.String newPassword) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionChanges the user on this connection by performing a re-authentication. If authentication fails, the connection is failed.- Specified by:
changeUserin interfaceJdbcConnection- Overrides:
changeUserin classMultiHostMySQLConnection- Parameters:
userName- the username to authenticate withnewPassword- the password to authenticate with- Throws:
java.sql.SQLException- if authentication fails, or some other error occurs while performing the command.
-
setStatementComment
public void setStatementComment(java.lang.String comment)Description copied from interface:JdbcConnectionSets the comment that will be prepended to all statements sent to the server. Do not use slash-star or star-slash tokens in the comment as these will be added by the driver itself.- Specified by:
setStatementCommentin interfaceJdbcConnection- Overrides:
setStatementCommentin classMultiHostMySQLConnection- Parameters:
comment- the comment that will be prepended to all statements sent to the server.
-
hasSameProperties
Description copied from interface:JdbcConnectionDoes this connection have the same properties as another?- Specified by:
hasSamePropertiesin interfaceJdbcConnection- Overrides:
hasSamePropertiesin classMultiHostMySQLConnection- Parameters:
c- connection- Returns:
- true if has the same properties
-
getProperties
public java.util.Properties getProperties()Description copied from interface:MysqlConnectionReturns the parsed and passed in properties for this connection.- Specified by:
getPropertiesin interfaceMysqlConnection- Overrides:
getPropertiesin classMultiHostMySQLConnection- Returns:
Properties
-
abort
public void abort(java.util.concurrent.Executor executor) throws java.sql.SQLException- Specified by:
abortin interfacejava.sql.Connection- Overrides:
abortin classMultiHostMySQLConnection- Throws:
java.sql.SQLException
-
abortInternal
public void abortInternal() throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionClobbers the physical network connection and marks this connection as closed.- Specified by:
abortInternalin interfaceJdbcConnection- Overrides:
abortInternalin classMultiHostMySQLConnection- Throws:
java.sql.SQLException- if an error occurs
-
setProxy
- Specified by:
setProxyin interfaceJdbcConnection- Overrides:
setProxyin classMultiHostMySQLConnection
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException- Specified by:
isWrapperForin interfacejava.sql.Wrapper- Overrides:
isWrapperForin classMultiHostMySQLConnection- Throws:
java.sql.SQLException
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException- Specified by:
unwrapin interfacejava.sql.Wrapper- Overrides:
unwrapin classMultiHostMySQLConnection- Throws:
java.sql.SQLException
-
clearHasTriedMaster
@Deprecated public void clearHasTriedMaster()Deprecated.- Specified by:
clearHasTriedMasterin interfaceJdbcConnection- Overrides:
clearHasTriedMasterin classMultiHostMySQLConnection
-