接口 JdbcConnection
-
- 所有已知子接口:
LoadBalancedConnection,ReplicationConnection
- 所有已知实现类:
ConnectionImpl,ConnectionWrapper,LoadBalancedMySQLConnection,MultiHostMySQLConnection,ReplicationMySQLConnection
public interface JdbcConnection extends Connection, MysqlConnection, TransactionEventHandler
This interface contains methods that are considered the "vendor extension" to the JDBC API for MySQL's implementation of java.sql.Connection. For those looking further into the driver implementation, it is not an API that is used for plugability of implementations inside our driver (which is why there are still references to ConnectionImpl throughout the code).
-
-
方法概要
所有方法 实例方法 抽象方法 默认方法 已过时的方法 修饰符和类型 方法 说明 voidabortInternal()Clobbers the physical network connection and marks this connection as closed.voidchangeUser(String userName, String newPassword)Changes the user on this connection by performing a re-authentication.voidclearHasTriedMaster()已过时。PreparedStatementclientPrepareStatement(String sql)Prepares a statement on the client, using client-side emulation (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.PreparedStatementclientPrepareStatement(String sql, int autoGenKeyIndex)Prepares a statement on the client, using client-side emulation (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.PreparedStatementclientPrepareStatement(String sql, int[] autoGenKeyIndexes)Prepares a statement on the client, using client-side emulation (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.PreparedStatementclientPrepareStatement(String sql, int resultSetType, int resultSetConcurrency)Prepares a statement on the client, using client-side emulation (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.PreparedStatementclientPrepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)Prepares a statement on the client, using client-side emulation (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.PreparedStatementclientPrepareStatement(String sql, String[] autoGenKeyColNames)Prepares a statement on the client, using client-side emulation (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.voiddecachePreparedStatement(JdbcPreparedStatement pstmt)JdbcConnectiongetActiveMySQLConnection()intgetActiveStatementCount()Returns the number of statements active on this connection, which haven't been .close()d.intgetAutoIncrementIncrement()Returns the -session- value of 'auto_increment_increment' from the server if it exists, or '1' if not.CachedResultSetMetaDatagetCachedMetaData(String sql)Returns cached metadata (or null if not cached) for the given query, which must match _exactly_.StringgetCharacterSetMetadata()ClientInfoProvidergetClientInfoProviderImpl()StringgetDatabase()Retrieves this connection object's current database name.StringgetHost()StringgetHostPortPair()longgetIdleFor()Reports how long this connection has been idle.StatementgetMetadataSafeStatement()JdbcConnectiongetMultiHostParentProxy()JdbcConnectiongetMultiHostSafeProxy()JdbcPropertySetgetPropertySet()List<QueryInterceptor>getQueryInterceptorsInstances()ServerVersiongetServerVersion()intgetSessionMaxRows()Returns the sql select limit max-rows for this session.StringgetStatementComment()Returns the comment that will be prepended to all statements sent to the server.booleanhasSameProperties(JdbcConnection c)Does this connection have the same properties as another?booleanhasTriedMaster()已过时。voidinitializeResultsMetadataFromCache(String sql, CachedResultSetMetaData cachedMetaData, ResultSetInternalMethods resultSet)Caches CachedResultSetMetaData that has been placed in the cache using the given SQL as a key.voidinitializeSafeQueryInterceptors()booleanisInGlobalTx()Is this connection currently a participant in an XA transaction?default booleanisMasterConnection()已过时。booleanisProxySet()booleanisReadOnly(boolean useSessionStatus)Tests to see if the connection is in Read Only Mode.booleanisSameResource(JdbcConnection c)Does this connection have the same resource name as the given connection (for XA)?booleanisServerLocal()Is the server this connection is connected to "local" (i.e. same host) as the application?booleanisSourceConnection()Is this connection connected to the first host in the list if there is a list of servers in the URL?booleanlowerCaseTableNames()Is the server configured to use lower-case table names only?voidping()Detect if the connection is still good by sending a ping command to the server.voidpingInternal(boolean checkForClosedConnection, int timeoutMillis)voidrealClose(boolean calledExplicitly, boolean issueRollback, boolean skipLocalTeardown, Throwable reason)Closes connection and frees resources.voidrecachePreparedStatement(JdbcPreparedStatement pstmt)voidregisterStatement(JdbcStatement stmt)Register a Statement instance as open.voidresetServerState()Resets the server-side state of this connection.PreparedStatementserverPrepareStatement(String sql)Prepares a statement on the server (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.PreparedStatementserverPrepareStatement(String sql, int autoGenKeyIndex)Prepares a statement on the server (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.PreparedStatementserverPrepareStatement(String sql, int[] autoGenKeyIndexes)Prepares a statement on the server (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.PreparedStatementserverPrepareStatement(String sql, int resultSetType, int resultSetConcurrency)Prepares a statement on the server (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.PreparedStatementserverPrepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)Prepares a statement on the server (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.PreparedStatementserverPrepareStatement(String sql, String[] autoGenKeyColNames)Prepares a statement on the server (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.voidsetDatabase(String dbName)Set current database for this connection.voidsetFailedOver(boolean flag)voidsetInGlobalTx(boolean flag)Set the state of being in a global (XA) transaction.voidsetProxy(JdbcConnection proxy)voidsetReadOnlyInternal(boolean readOnlyFlag)voidsetSessionMaxRows(int max)Sets the sql select limit max-rows for this session if different from current.voidsetStatementComment(String comment)Sets the comment that will be prepended to all statements sent to the server.voidshutdownServer()Used by MiniAdmin to shutdown a MySQL serverbooleanstoresLowerCaseTableName()voidthrowConnectionClosedException()voidunregisterStatement(JdbcStatement stmt)Remove the given statement from the list of open statementsvoidunSafeQueryInterceptors()-
从接口继承的方法 java.sql.Connection
abort, 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, 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
-
从接口继承的方法 com.mysql.cj.MysqlConnection
checkClosed, cleanup, createNewIO, getConnectionMutex, getExceptionInterceptor, getId, getProperties, getServerSessionStateController, getSession, getURL, getUser, normalClose
-
从接口继承的方法 com.mysql.cj.TransactionEventHandler
transactionBegun, transactionCompleted
-
从接口继承的方法 java.sql.Wrapper
isWrapperFor, unwrap
-
-
-
-
方法详细资料
-
getPropertySet
JdbcPropertySet getPropertySet()
- 指定者:
getPropertySet在接口中MysqlConnection
-
changeUser
void changeUser(String userName, String newPassword) throws SQLException
Changes the user on this connection by performing a re-authentication. If authentication fails, the connection is failed.- 参数:
userName- the username to authenticate withnewPassword- the password to authenticate with- 抛出:
SQLException- if authentication fails, or some other error occurs while performing the command.
-
clearHasTriedMaster
@Deprecated void clearHasTriedMaster()
已过时。
-
clientPrepareStatement
PreparedStatement clientPrepareStatement(String sql) throws SQLException
Prepares a statement on the client, using client-side emulation (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.- 参数:
sql- statement- 返回:
- prepared statement
- 抛出:
SQLException- if an error occurs- 另请参阅:
Connection.prepareStatement(String)
-
clientPrepareStatement
PreparedStatement clientPrepareStatement(String sql, int autoGenKeyIndex) throws SQLException
Prepares a statement on the client, using client-side emulation (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.- 参数:
sql- statementautoGenKeyIndex- autoGenKeyIndex- 返回:
- prepared statement
- 抛出:
SQLException- if an error occurs- 另请参阅:
Connection.prepareStatement(String, int)
-
clientPrepareStatement
PreparedStatement clientPrepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
Prepares a statement on the client, using client-side emulation (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.- 参数:
sql- statementresultSetType- resultSetTyperesultSetConcurrency- resultSetConcurrency- 返回:
- prepared statement
- 抛出:
SQLException- if an error occurs- 另请参阅:
Connection.prepareStatement(String, int, int)
-
clientPrepareStatement
PreparedStatement clientPrepareStatement(String sql, int[] autoGenKeyIndexes) throws SQLException
Prepares a statement on the client, using client-side emulation (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.- 参数:
sql- statementautoGenKeyIndexes- autoGenKeyIndexes- 返回:
- prepared statement
- 抛出:
SQLException- if an error occurs- 另请参阅:
Connection.prepareStatement(String, int[])
-
clientPrepareStatement
PreparedStatement clientPrepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
Prepares a statement on the client, using client-side emulation (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.- 参数:
sql- statementresultSetType- resultSetTyperesultSetConcurrency- resultSetConcurrencyresultSetHoldability- resultSetHoldability- 返回:
- prepared statement
- 抛出:
SQLException- if an error occurs- 另请参阅:
Connection.prepareStatement(String, int, int, int)
-
clientPrepareStatement
PreparedStatement clientPrepareStatement(String sql, String[] autoGenKeyColNames) throws SQLException
Prepares a statement on the client, using client-side emulation (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.- 参数:
sql- statementautoGenKeyColNames- autoGenKeyColNames- 返回:
- prepared statement
- 抛出:
SQLException- if an error occurs- 另请参阅:
Connection.prepareStatement(String, String[])
-
getActiveStatementCount
int getActiveStatementCount()
Returns the number of statements active on this connection, which haven't been .close()d.- 返回:
- the number of active statements
-
getIdleFor
long getIdleFor()
Reports how long this connection has been idle. This time (reported in milliseconds) is updated once a query has completed.- 返回:
- number of ms that this connection has been idle, 0 if the driver is busy retrieving results.
-
getStatementComment
String getStatementComment()
Returns the comment that will be prepended to all statements sent to the server.- 返回:
- the comment that will be prepended to all statements sent to the server.
-
hasTriedMaster
@Deprecated boolean hasTriedMaster()
已过时。Has this connection tried to execute a query on the "source" server (first host in a multiple host list).- 返回:
- true if it has tried
-
isInGlobalTx
boolean isInGlobalTx()
Is this connection currently a participant in an XA transaction?- 返回:
- true if this connection currently a participant in an XA transaction
-
setInGlobalTx
void setInGlobalTx(boolean flag)
Set the state of being in a global (XA) transaction.- 参数:
flag- the state flag
-
isSourceConnection
boolean isSourceConnection()
Is this connection connected to the first host in the list if there is a list of servers in the URL?- 返回:
- true if this connection is connected to the first in the list.
-
isMasterConnection
@Deprecated default boolean isMasterConnection()
已过时。UseisSourceConnection()instead.- 返回:
- true if it's a source connection
-
isSameResource
boolean isSameResource(JdbcConnection c)
Does this connection have the same resource name as the given connection (for XA)?- 参数:
c- connection- 返回:
- true if it is the same one
-
lowerCaseTableNames
boolean lowerCaseTableNames()
Is the server configured to use lower-case table names only?- 返回:
- true if lower_case_table_names is 'on'
-
ping
void ping() throws SQLException
Detect if the connection is still good by sending a ping command to the server.- 抛出:
SQLException- if the ping fails
-
resetServerState
void resetServerState() throws SQLExceptionResets the server-side state of this connection. Doesn't work if isParanoid() is set (it will become a no-op in this case). Usually only used from connection pooling code.- 抛出:
SQLException- if the operation fails while resetting server state.
-
serverPrepareStatement
PreparedStatement serverPrepareStatement(String sql) throws SQLException
Prepares a statement on the server (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.- 参数:
sql- statement- 返回:
- prepared statement
- 抛出:
SQLException- if an error occurs- 另请参阅:
Connection.prepareStatement(String)
-
serverPrepareStatement
PreparedStatement serverPrepareStatement(String sql, int autoGenKeyIndex) throws SQLException
Prepares a statement on the server (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.- 参数:
sql- statementautoGenKeyIndex- autoGenKeyIndex- 返回:
- prepared statement
- 抛出:
SQLException- if an error occurs- 另请参阅:
Connection.prepareStatement(String, int)
-
serverPrepareStatement
PreparedStatement serverPrepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
Prepares a statement on the server (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.- 参数:
sql- statementresultSetType- resultSetTyperesultSetConcurrency- resultSetConcurrency- 返回:
- prepared statement
- 抛出:
SQLException- if an error occurs- 另请参阅:
Connection.prepareStatement(String, int, int)
-
serverPrepareStatement
PreparedStatement serverPrepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
Prepares a statement on the server (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.- 参数:
sql- statementresultSetType- resultSetTyperesultSetConcurrency- resultSetConcurrencyresultSetHoldability- resultSetHoldability- 返回:
- prepared statement
- 抛出:
SQLException- if an error occurs- 另请参阅:
Connection.prepareStatement(String, int, int, int)
-
serverPrepareStatement
PreparedStatement serverPrepareStatement(String sql, int[] autoGenKeyIndexes) throws SQLException
Prepares a statement on the server (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.- 参数:
sql- statementautoGenKeyIndexes- autoGenKeyIndexes- 返回:
- prepared statement
- 抛出:
SQLException- if an error occurs- 另请参阅:
Connection.prepareStatement(String, int[])
-
serverPrepareStatement
PreparedStatement serverPrepareStatement(String sql, String[] autoGenKeyColNames) throws SQLException
Prepares a statement on the server (irregardless of the configuration property 'useServerPrepStmts') with the same semantics as the java.sql.Connection.prepareStatement() method with the same argument types.- 参数:
sql- statementautoGenKeyColNames- autoGenKeyColNames- 返回:
- prepared statement
- 抛出:
SQLException- if an error occurs- 另请参阅:
Connection.prepareStatement(String, String[])
-
setFailedOver
void setFailedOver(boolean flag)
- 参数:
flag- The failedOver flag to set.
-
setStatementComment
void setStatementComment(String comment)
Sets 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.- 参数:
comment- the comment that will be prepended to all statements sent to the server.
-
shutdownServer
void shutdownServer() throws SQLExceptionUsed by MiniAdmin to shutdown a MySQL server- 抛出:
SQLException- if the command can not be issued.
-
getAutoIncrementIncrement
int getAutoIncrementIncrement()
Returns the -session- value of 'auto_increment_increment' from the server if it exists, or '1' if not.- 返回:
- the -session- value of 'auto_increment_increment'
-
hasSameProperties
boolean hasSameProperties(JdbcConnection c)
Does this connection have the same properties as another?- 参数:
c- connection- 返回:
- true if has the same properties
-
getHost
String getHost()
-
getHostPortPair
String getHostPortPair()
-
setProxy
void setProxy(JdbcConnection proxy)
-
isServerLocal
boolean isServerLocal() throws SQLExceptionIs the server this connection is connected to "local" (i.e. same host) as the application?- 返回:
- true if the server is "local"
- 抛出:
SQLException- if an error occurs
-
getSessionMaxRows
int getSessionMaxRows()
Returns the sql select limit max-rows for this session.- 返回:
- int max rows
-
setSessionMaxRows
void setSessionMaxRows(int max) throws SQLExceptionSets the sql select limit max-rows for this session if different from current.- 参数:
max- the new max-rows value to set.- 抛出:
SQLException- if a database error occurs issuing the statement that sets the limit.
-
abortInternal
void abortInternal() throws SQLExceptionClobbers the physical network connection and marks this connection as closed.- 抛出:
SQLException- if an error occurs
-
isProxySet
boolean isProxySet()
-
getCachedMetaData
CachedResultSetMetaData getCachedMetaData(String sql)
Returns cached metadata (or null if not cached) for the given query, which must match _exactly_. This method is synchronized by the caller on getMutex(), so if calling this method from internal code in the driver, make sure it's synchronized on the mutex that guards communication with the server.- 参数:
sql- the query that is the key to the cache- 返回:
- metadata cached for the given SQL, or none if it doesn't exist.
-
getCharacterSetMetadata
String getCharacterSetMetadata()
- 返回:
- Returns the characterSetMetadata.
-
getMetadataSafeStatement
Statement getMetadataSafeStatement() throws SQLException
- 抛出:
SQLException
-
getServerVersion
ServerVersion getServerVersion()
-
getQueryInterceptorsInstances
List<QueryInterceptor> getQueryInterceptorsInstances()
-
initializeResultsMetadataFromCache
void initializeResultsMetadataFromCache(String sql, CachedResultSetMetaData cachedMetaData, ResultSetInternalMethods resultSet) throws SQLException
Caches CachedResultSetMetaData that has been placed in the cache using the given SQL as a key. This method is synchronized by the caller on getMutex(), so if calling this method from internal code in the driver, make sure it's synchronized on the mutex that guards communication with the server.- 参数:
sql- the query that the metadata pertains too.cachedMetaData- metadata (if it exists) to populate the cache.resultSet- the result set to retreive metadata from, or apply to.- 抛出:
SQLException- if an error occurs
-
initializeSafeQueryInterceptors
void initializeSafeQueryInterceptors() throws SQLException- 抛出:
SQLException
-
isReadOnly
boolean isReadOnly(boolean useSessionStatus) throws SQLExceptionTests to see if the connection is in Read Only Mode.- 参数:
useSessionStatus- in some cases, for example when restoring connection with autoReconnect=true, we can rely only on saved readOnly state, so use useSessionStatus=false in that case- 返回:
- true if the connection is read only
- 抛出:
SQLException- if a database access error occurs
-
pingInternal
void pingInternal(boolean checkForClosedConnection, int timeoutMillis) throws SQLException- 抛出:
SQLException
-
realClose
void realClose(boolean calledExplicitly, boolean issueRollback, boolean skipLocalTeardown, Throwable reason) throws SQLExceptionCloses connection and frees resources.- 参数:
calledExplicitly- is this being called from close()issueRollback- should a rollback() be issued?skipLocalTeardown- if true, driver tries to close connection normally, performing rollbacks, closing open statements etc; otherwise the force close is performedreason- the exception caused this method call- 抛出:
SQLException- if an error occurs
-
recachePreparedStatement
void recachePreparedStatement(JdbcPreparedStatement pstmt) throws SQLException
- 抛出:
SQLException
-
decachePreparedStatement
void decachePreparedStatement(JdbcPreparedStatement pstmt) throws SQLException
- 抛出:
SQLException
-
registerStatement
void registerStatement(JdbcStatement stmt)
Register a Statement instance as open.- 参数:
stmt- the Statement instance to remove
-
setReadOnlyInternal
void setReadOnlyInternal(boolean readOnlyFlag) throws SQLException- 抛出:
SQLException
-
storesLowerCaseTableName
boolean storesLowerCaseTableName()
-
throwConnectionClosedException
void throwConnectionClosedException() throws SQLException- 抛出:
SQLException
-
unregisterStatement
void unregisterStatement(JdbcStatement stmt)
Remove the given statement from the list of open statements- 参数:
stmt- the Statement instance to remove
-
unSafeQueryInterceptors
void unSafeQueryInterceptors() throws SQLException- 抛出:
SQLException
-
getMultiHostSafeProxy
JdbcConnection getMultiHostSafeProxy()
-
getMultiHostParentProxy
JdbcConnection getMultiHostParentProxy()
-
getActiveMySQLConnection
JdbcConnection getActiveMySQLConnection()
-
getClientInfoProviderImpl
ClientInfoProvider getClientInfoProviderImpl() throws SQLException
- 抛出:
SQLException
-
setDatabase
void setDatabase(String dbName) throws SQLException
Set current database for this connection.- 参数:
dbName- the database for this connection to use- 抛出:
SQLException- if a database access error occurs
-
getDatabase
String getDatabase() throws SQLException
Retrieves this connection object's current database name.- 返回:
- current database name
- 抛出:
SQLException- if an error occurs
-
-