Package com.mysql.cj.jdbc
Class ConnectionImpl
java.lang.Object
com.mysql.cj.jdbc.ConnectionImpl
- All Implemented Interfaces:
JdbcConnection,MysqlConnection,Session.SessionEventListener,TransactionEventHandler,java.io.Serializable,java.lang.AutoCloseable,java.sql.Connection,java.sql.Wrapper
public class ConnectionImpl extends java.lang.Object implements JdbcConnection, Session.SessionEventListener, java.io.Serializable
A Connection represents a session with a specific database. Within the context of a Connection, SQL statements are executed and results are returned.
A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc. This information is obtained with the getMetaData method.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static java.util.Map<?,?>charsetMapThe mapping between MySQL charset names and Java charset names.protected static java.lang.StringDEFAULT_LOGGER_CLASSDefault logger class nameprotected ResultSetFactorynullStatementResultSetFactoryprotected JdbcPropertySetpropertySetprotected java.util.PropertiespropsProperties for this connection specified by userprotected LRUCache<java.lang.String,CachedResultSetMetaData>resultSetMetadataCacheCache of ResultSet metadataprotected static java.util.Map<?,?>roundRobinStatsMap -
Constructor Summary
Constructors Modifier Constructor Description protectedConnectionImpl()' For the delegate onlyConnectionImpl(HostInfo hostInfo)Creates a connection to a MySQL Server. -
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.voidchangeUser(java.lang.String userName, java.lang.String newPassword)Changes the user on this connection by performing a re-authentication.voidcheckClosed()voidcleanup(java.lang.Throwable whyCleanedUp)Destroys this connection and any underlying resources.voidclearHasTriedMaster()Deprecated.voidclearWarnings()java.sql.PreparedStatementclientPrepareStatement(java.lang.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.java.sql.PreparedStatementclientPrepareStatement(java.lang.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.java.sql.PreparedStatementclientPrepareStatement(java.lang.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.java.sql.PreparedStatementclientPrepareStatement(java.lang.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.java.sql.PreparedStatementclientPrepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, boolean processEscapeCodesIfNeeded)java.sql.PreparedStatementclientPrepareStatement(java.lang.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.java.sql.PreparedStatementclientPrepareStatement(java.lang.String sql, java.lang.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.voidclose()voidcommit()java.sql.ArraycreateArrayOf(java.lang.String typeName, java.lang.Object[] elements)java.sql.BlobcreateBlob()java.sql.ClobcreateClob()java.sql.NClobcreateNClob()voidcreateNewIO(boolean isForReconnect)Creates an IO channel to the server.java.sql.SQLXMLcreateSQLXML()java.sql.StatementcreateStatement()java.sql.StatementcreateStatement(int resultSetType, int resultSetConcurrency)java.sql.StatementcreateStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)java.sql.StructcreateStruct(java.lang.String typeName, java.lang.Object[] attributes)voiddecachePreparedStatement(JdbcPreparedStatement pstmt)JdbcConnectiongetActiveMySQLConnection()intgetActiveStatementCount()Returns the number of statements active on this connection, which haven't been .close()d.booleangetAutoCommit()intgetAutoIncrementIncrement()Returns the -session- value of 'auto_increment_increment' from the server if it exists, or '1' if not.CachedResultSetMetaDatagetCachedMetaData(java.lang.String sql)Returns cached metadata (or null if not cached) for the given query, which must match _exactly_.java.lang.StringgetCatalog()java.lang.StringgetCharacterSetMetadata()java.util.PropertiesgetClientInfo()java.lang.StringgetClientInfo(java.lang.String name)ClientInfoProvidergetClientInfoProviderImpl()java.lang.ObjectgetConnectionMutex()java.lang.StringgetDatabase()Retrieves this connection object's current database name.ExceptionInterceptorgetExceptionInterceptor()intgetHoldability()java.lang.StringgetHost()java.lang.StringgetHostPortPair()longgetId()longgetIdleFor()NOT JDBC-Compliant, but clients can use this method to determine how long this connection has been idle.static JdbcConnectiongetInstance(HostInfo hostInfo)Creates a connection instance.java.sql.DatabaseMetaDatagetMetaData()java.sql.StatementgetMetadataSafeStatement()java.sql.StatementgetMetadataSafeStatement(int maxRows)JdbcConnectiongetMultiHostParentProxy()JdbcConnectiongetMultiHostSafeProxy()intgetNetworkTimeout()protected static intgetNextRoundRobinHostIndex(java.lang.String url, java.util.List<?> hostList)java.util.PropertiesgetProperties()Returns the parsed and passed in properties for this connection.JdbcPropertySetgetPropertySet()java.util.List<QueryInterceptor>getQueryInterceptorsInstances()java.lang.StringgetSchema()ServerVersiongetServerVersion()NativeSessiongetSession()intgetSessionMaxRows()Returns the sql select limit max-rows for this session.java.lang.StringgetStatementComment()Returns the comment that will be prepended to all statements sent to the server.intgetTransactionIsolation()java.util.Map<java.lang.String,java.lang.Class<?>>getTypeMap()java.lang.StringgetURL()java.lang.StringgetUser()java.sql.SQLWarninggetWarnings()voidhandleCleanup(java.lang.Throwable whyCleanedUp)voidhandleNormalClose()voidhandleReconnect()booleanhasSameProperties(JdbcConnection c)Does this connection have the same properties as another?booleanhasTriedMaster()Deprecated.voidinitializeResultsMetadataFromCache(java.lang.String sql, CachedResultSetMetaData cachedMetaData, ResultSetInternalMethods resultSet)Caches CachedResultSetMetaData that has been placed in the cache using the given SQL as a key.voidinitializeSafeQueryInterceptors()booleanisClosed()booleanisInGlobalTx()Is this connection currently a participant in an XA transaction?booleanisProxySet()booleanisReadOnly()booleanisReadOnly(boolean useSessionStatus)Tests to see if the connection is in Read Only Mode.booleanisSameResource(JdbcConnection otherConnection)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.booleanisSourceConnection()Is this connection connected to the first host in the list if there is a list of servers in the URL?booleanisValid(int timeout)booleanisWrapperFor(java.lang.Class<?> iface)booleanlowerCaseTableNames()Is the server configured to use lower-case table names only?java.lang.StringnativeSQL(java.lang.String sql)voidnormalClose()voidping()Detect if the connection is still good by sending a ping command to the server.voidpingInternal(boolean checkForClosedConnection, int timeoutMillis)java.sql.CallableStatementprepareCall(java.lang.String sql)java.sql.CallableStatementprepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)java.sql.CallableStatementprepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)java.sql.PreparedStatementprepareStatement(java.lang.String sql)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int autoGenKeyIndex)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int[] autoGenKeyIndexes)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)java.sql.PreparedStatementprepareStatement(java.lang.String sql, java.lang.String[] autoGenKeyColNames)voidrealClose(boolean calledExplicitly, boolean issueRollback, boolean skipLocalTeardown, java.lang.Throwable reason)Closes connection and frees resources.voidrecachePreparedStatement(JdbcPreparedStatement pstmt)voidregisterStatement(JdbcStatement stmt)Register a Statement instance as open.voidreleaseSavepoint(java.sql.Savepoint arg0)voidresetServerState()Resets the server-side state of this connection.voidrollback()voidrollback(java.sql.Savepoint savepoint)java.sql.PreparedStatementserverPrepareStatement(java.lang.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.java.sql.PreparedStatementserverPrepareStatement(java.lang.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.java.sql.PreparedStatementserverPrepareStatement(java.lang.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.java.sql.PreparedStatementserverPrepareStatement(java.lang.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.java.sql.PreparedStatementserverPrepareStatement(java.lang.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.java.sql.PreparedStatementserverPrepareStatement(java.lang.String sql, java.lang.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.voidsetAutoCommit(boolean autoCommitFlag)voidsetCatalog(java.lang.String catalog)voidsetClientInfo(java.lang.String name, java.lang.String value)voidsetClientInfo(java.util.Properties properties)voidsetDatabase(java.lang.String db)Set current database for this connection.voidsetFailedOver(boolean flag)voidsetHoldability(int arg0)voidsetInGlobalTx(boolean flag)Set the state of being in a global (XA) transaction.voidsetNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds)voidsetProxy(JdbcConnection proxy)voidsetReadOnly(boolean readOnlyFlag)voidsetReadOnlyInternal(boolean readOnlyFlag)java.sql.SavepointsetSavepoint()java.sql.SavepointsetSavepoint(java.lang.String name)voidsetSchema(java.lang.String schema)voidsetSessionMaxRows(int max)Sets the sql select limit max-rows for this session if different from current.voidsetStatementComment(java.lang.String comment)Sets the comment that will be prepended to all statements sent to the server.voidsetTransactionIsolation(int level)voidsetTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> map)voidshutdownServer()Used by MiniAdmin to shutdown a MySQL serverbooleanstoresLowerCaseTableName()voidthrowConnectionClosedException()voidtransactionBegun()voidtransactionCompleted()voidunregisterStatement(JdbcStatement stmt)Remove the given statement from the list of open statementsvoidunSafeQueryInterceptors()<T> Tunwrap(java.lang.Class<T> iface)booleanversionMeetsMinimum(int major, int minor, int subminor)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
charsetMap
public static java.util.Map<?,?> charsetMapThe mapping between MySQL charset names and Java charset names. Initialized by loadCharacterSetMapping() -
DEFAULT_LOGGER_CLASS
protected static final java.lang.String DEFAULT_LOGGER_CLASSDefault logger class name -
roundRobinStatsMap
protected static java.util.Map<?,?> roundRobinStatsMap -
props
protected java.util.Properties propsProperties for this connection specified by user -
resultSetMetadataCache
Cache of ResultSet metadata -
propertySet
-
nullStatementResultSetFactory
-
-
Constructor Details
-
ConnectionImpl
protected ConnectionImpl()' For the delegate only -
ConnectionImpl
Creates a connection to a MySQL Server.- Parameters:
hostInfo- theHostInfoinstance that contains the host, user and connections attributes for this connection- Throws:
java.sql.SQLException- if a database access error occurs
-
-
Method Details
-
getHost
public java.lang.String getHost()- Specified by:
getHostin interfaceJdbcConnection
-
isProxySet
public boolean isProxySet()- Specified by:
isProxySetin interfaceJdbcConnection
-
setProxy
- Specified by:
setProxyin interfaceJdbcConnection
-
getMultiHostSafeProxy
- Specified by:
getMultiHostSafeProxyin interfaceJdbcConnection
-
getMultiHostParentProxy
- Specified by:
getMultiHostParentProxyin interfaceJdbcConnection
-
getActiveMySQLConnection
- Specified by:
getActiveMySQLConnectionin interfaceJdbcConnection
-
getConnectionMutex
public java.lang.Object getConnectionMutex()- Specified by:
getConnectionMutexin interfaceMysqlConnection
-
getInstance
Creates a connection instance.- Parameters:
hostInfo-HostInfoinstance- Returns:
- new
ConnectionImplinstance - Throws:
java.sql.SQLException- if a database access error occurs
-
getNextRoundRobinHostIndex
protected static int getNextRoundRobinHostIndex(java.lang.String url, java.util.List<?> hostList)- Parameters:
url- connection URLhostList- hosts list- Returns:
- index in a host list
-
getPropertySet
- Specified by:
getPropertySetin interfaceJdbcConnection- Specified by:
getPropertySetin interfaceMysqlConnection
-
unSafeQueryInterceptors
public void unSafeQueryInterceptors() throws java.sql.SQLException- Specified by:
unSafeQueryInterceptorsin interfaceJdbcConnection- Throws:
java.sql.SQLException
-
initializeSafeQueryInterceptors
public void initializeSafeQueryInterceptors() throws java.sql.SQLException- Specified by:
initializeSafeQueryInterceptorsin interfaceJdbcConnection- Throws:
java.sql.SQLException
-
getQueryInterceptorsInstances
- Specified by:
getQueryInterceptorsInstancesin interfaceJdbcConnection
-
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- 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.
-
checkClosed
public void checkClosed()- Specified by:
checkClosedin interfaceMysqlConnection
-
throwConnectionClosedException
public void throwConnectionClosedException() throws java.sql.SQLException- Specified by:
throwConnectionClosedExceptionin interfaceJdbcConnection- 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- Throws:
java.sql.SQLException- if an error occurs
-
cleanup
public void cleanup(java.lang.Throwable whyCleanedUp)Description copied from interface:MysqlConnectionDestroys this connection and any underlying resources.- Specified by:
cleanupin interfaceMysqlConnection- Parameters:
whyCleanedUp- exception caused the connection clean up
-
clearHasTriedMaster
@Deprecated public void clearHasTriedMaster()Deprecated.- Specified by:
clearHasTriedMasterin interfaceJdbcConnection
-
clearWarnings
public void clearWarnings() throws java.sql.SQLException- Specified by:
clearWarningsin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
clientPrepareStatement
public java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionPrepares 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.- Specified by:
clientPrepareStatementin interfaceJdbcConnection- Parameters:
sql- statement- Returns:
- prepared statement
- Throws:
java.sql.SQLException- if an error occurs- See Also:
Connection.prepareStatement(String)
-
clientPrepareStatement
public java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql, int autoGenKeyIndex) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionPrepares 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.- Specified by:
clientPrepareStatementin interfaceJdbcConnection- Parameters:
sql- statementautoGenKeyIndex- autoGenKeyIndex- Returns:
- prepared statement
- Throws:
java.sql.SQLException- if an error occurs- See Also:
Connection.prepareStatement(String, int)
-
clientPrepareStatement
public java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionPrepares 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.- Specified by:
clientPrepareStatementin interfaceJdbcConnection- Parameters:
sql- statementresultSetType- resultSetTyperesultSetConcurrency- resultSetConcurrency- Returns:
- prepared statement
- Throws:
java.sql.SQLException- if an error occurs- See Also:
Connection.prepareStatement(String, int, int)
-
clientPrepareStatement
public java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, boolean processEscapeCodesIfNeeded) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
clientPrepareStatement
public java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql, int[] autoGenKeyIndexes) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionPrepares 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.- Specified by:
clientPrepareStatementin interfaceJdbcConnection- Parameters:
sql- statementautoGenKeyIndexes- autoGenKeyIndexes- Returns:
- prepared statement
- Throws:
java.sql.SQLException- if an error occurs- See Also:
Connection.prepareStatement(String, int[])
-
clientPrepareStatement
public java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql, java.lang.String[] autoGenKeyColNames) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionPrepares 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.- Specified by:
clientPrepareStatementin interfaceJdbcConnection- Parameters:
sql- statementautoGenKeyColNames- autoGenKeyColNames- Returns:
- prepared statement
- Throws:
java.sql.SQLException- if an error occurs- See Also:
Connection.prepareStatement(String, String[])
-
clientPrepareStatement
public java.sql.PreparedStatement clientPrepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionPrepares 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.- Specified by:
clientPrepareStatementin interfaceJdbcConnection- Parameters:
sql- statementresultSetType- resultSetTyperesultSetConcurrency- resultSetConcurrencyresultSetHoldability- resultSetHoldability- Returns:
- prepared statement
- Throws:
java.sql.SQLException- if an error occurs- See Also:
Connection.prepareStatement(String, int, int, int)
-
close
public void close() throws java.sql.SQLException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
normalClose
public void normalClose()- Specified by:
normalClosein interfaceMysqlConnection
-
commit
public void commit() throws java.sql.SQLException- Specified by:
commitin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createNewIO
public void createNewIO(boolean isForReconnect)Description copied from interface:MysqlConnectionCreates an IO channel to the server.- Specified by:
createNewIOin interfaceMysqlConnection- Parameters:
isForReconnect- is this request for a re-connect
-
createStatement
public java.sql.Statement createStatement() throws java.sql.SQLException- Specified by:
createStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createStatement
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLException- Specified by:
createStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createStatement
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException- Specified by:
createStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getActiveStatementCount
public int getActiveStatementCount()Description copied from interface:JdbcConnectionReturns the number of statements active on this connection, which haven't been .close()d.- Specified by:
getActiveStatementCountin interfaceJdbcConnection- Returns:
- the number of active statements
-
getAutoCommit
public boolean getAutoCommit() throws java.sql.SQLException- Specified by:
getAutoCommitin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getCatalog
public java.lang.String getCatalog() throws java.sql.SQLException- Specified by:
getCatalogin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getCharacterSetMetadata
public java.lang.String getCharacterSetMetadata()- Specified by:
getCharacterSetMetadatain interfaceJdbcConnection- Returns:
- Returns the characterSetMetadata.
-
getHoldability
public int getHoldability() throws java.sql.SQLException- Specified by:
getHoldabilityin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getId
public long getId()- Specified by:
getIdin interfaceMysqlConnection
-
getIdleFor
public long getIdleFor()NOT JDBC-Compliant, but clients can use this method to determine how long this connection has been idle. This time (reported in milliseconds) is updated once a query has completed.- Specified by:
getIdleForin interfaceJdbcConnection- Returns:
- number of ms that this connection has been idle, 0 if the driver is busy retrieving results.
-
getMetaData
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException- Specified by:
getMetaDatain interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getMetadataSafeStatement
public java.sql.Statement getMetadataSafeStatement() throws java.sql.SQLException- Specified by:
getMetadataSafeStatementin interfaceJdbcConnection- Throws:
java.sql.SQLException
-
getMetadataSafeStatement
public java.sql.Statement getMetadataSafeStatement(int maxRows) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getServerVersion
- Specified by:
getServerVersionin interfaceJdbcConnection
-
getTransactionIsolation
public int getTransactionIsolation() throws java.sql.SQLException- Specified by:
getTransactionIsolationin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getTypeMap
public java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap() throws java.sql.SQLException- Specified by:
getTypeMapin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getURL
public java.lang.String getURL()- Specified by:
getURLin interfaceMysqlConnection
-
getUser
public java.lang.String getUser()- Specified by:
getUserin interfaceMysqlConnection
-
getWarnings
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException- Specified by:
getWarningsin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
hasSameProperties
Description copied from interface:JdbcConnectionDoes this connection have the same properties as another?- Specified by:
hasSamePropertiesin interfaceJdbcConnection- 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- Returns:
Properties
-
hasTriedMaster
@Deprecated public boolean hasTriedMaster()Deprecated.Description copied from interface:JdbcConnectionHas this connection tried to execute a query on the "source" server (first host in a multiple host list).- Specified by:
hasTriedMasterin interfaceJdbcConnection- Returns:
- true if it has tried
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfacejava.sql.Connection
-
isInGlobalTx
public boolean isInGlobalTx()Description copied from interface:JdbcConnectionIs this connection currently a participant in an XA transaction?- Specified by:
isInGlobalTxin interfaceJdbcConnection- Returns:
- true if this connection currently a participant in an XA transaction
-
isSourceConnection
public boolean isSourceConnection()Description copied from interface:JdbcConnectionIs this connection connected to the first host in the list if there is a list of servers in the URL?- Specified by:
isSourceConnectionin interfaceJdbcConnection- Returns:
- true if this connection is connected to the first in the list.
-
isReadOnly
public boolean isReadOnly() throws java.sql.SQLException- Specified by:
isReadOnlyin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
isReadOnly
public boolean isReadOnly(boolean useSessionStatus) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionTests to see if the connection is in Read Only Mode.- Specified by:
isReadOnlyin interfaceJdbcConnection- Parameters:
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- Returns:
- true if the connection is read only
- Throws:
java.sql.SQLException- if a database access error occurs
-
isSameResource
Description copied from interface:JdbcConnectionDoes this connection have the same resource name as the given connection (for XA)?- Specified by:
isSameResourcein interfaceJdbcConnection- Parameters:
otherConnection- connection- Returns:
- true if it is the same one
-
getAutoIncrementIncrement
public int getAutoIncrementIncrement()Description copied from interface:JdbcConnectionReturns the -session- value of 'auto_increment_increment' from the server if it exists, or '1' if not.- Specified by:
getAutoIncrementIncrementin interfaceJdbcConnection- Returns:
- the -session- value of 'auto_increment_increment'
-
lowerCaseTableNames
public boolean lowerCaseTableNames()Description copied from interface:JdbcConnectionIs the server configured to use lower-case table names only?- Specified by:
lowerCaseTableNamesin interfaceJdbcConnection- Returns:
- true if lower_case_table_names is 'on'
-
nativeSQL
public java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLException- Specified by:
nativeSQLin interfacejava.sql.Connection- 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- Throws:
java.sql.SQLException- if the ping fails
-
pingInternal
public void pingInternal(boolean checkForClosedConnection, int timeoutMillis) throws java.sql.SQLException- Specified by:
pingInternalin interfaceJdbcConnection- Throws:
java.sql.SQLException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException- Specified by:
prepareCallin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException- Specified by:
prepareCallin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException- Specified by:
prepareCallin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException- Specified by:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGenKeyIndex) throws java.sql.SQLException- Specified by:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException- Specified by:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException- Specified by:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] autoGenKeyIndexes) throws java.sql.SQLException- Specified by:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] autoGenKeyColNames) throws java.sql.SQLException- Specified by:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
realClose
public void realClose(boolean calledExplicitly, boolean issueRollback, boolean skipLocalTeardown, java.lang.Throwable reason) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionCloses connection and frees resources.- Specified by:
realClosein interfaceJdbcConnection- Parameters:
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- Throws:
java.sql.SQLException- if an error occurs
-
recachePreparedStatement
- Specified by:
recachePreparedStatementin interfaceJdbcConnection- Throws:
java.sql.SQLException
-
decachePreparedStatement
- Specified by:
decachePreparedStatementin interfaceJdbcConnection- Throws:
java.sql.SQLException
-
registerStatement
Description copied from interface:JdbcConnectionRegister a Statement instance as open.- Specified by:
registerStatementin interfaceJdbcConnection- Parameters:
stmt- the Statement instance to remove
-
releaseSavepoint
public void releaseSavepoint(java.sql.Savepoint arg0) throws java.sql.SQLException- Specified by:
releaseSavepointin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
resetServerState
public void resetServerState() throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionResets 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.- Specified by:
resetServerStatein interfaceJdbcConnection- Throws:
java.sql.SQLException- if the operation fails while resetting server state.
-
rollback
public void rollback() throws java.sql.SQLException- Specified by:
rollbackin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
rollback
public void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLException- Specified by:
rollbackin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
serverPrepareStatement
public java.sql.PreparedStatement serverPrepareStatement(java.lang.String sql) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionPrepares 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.- Specified by:
serverPrepareStatementin interfaceJdbcConnection- Parameters:
sql- statement- Returns:
- prepared statement
- Throws:
java.sql.SQLException- if an error occurs- See Also:
Connection.prepareStatement(String)
-
serverPrepareStatement
public java.sql.PreparedStatement serverPrepareStatement(java.lang.String sql, int autoGenKeyIndex) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionPrepares 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.- Specified by:
serverPrepareStatementin interfaceJdbcConnection- Parameters:
sql- statementautoGenKeyIndex- autoGenKeyIndex- Returns:
- prepared statement
- Throws:
java.sql.SQLException- if an error occurs- See Also:
Connection.prepareStatement(String, int)
-
serverPrepareStatement
public java.sql.PreparedStatement serverPrepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionPrepares 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.- Specified by:
serverPrepareStatementin interfaceJdbcConnection- Parameters:
sql- statementresultSetType- resultSetTyperesultSetConcurrency- resultSetConcurrency- Returns:
- prepared statement
- Throws:
java.sql.SQLException- if an error occurs- See Also:
Connection.prepareStatement(String, int, int)
-
serverPrepareStatement
public java.sql.PreparedStatement serverPrepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionPrepares 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.- Specified by:
serverPrepareStatementin interfaceJdbcConnection- Parameters:
sql- statementresultSetType- resultSetTyperesultSetConcurrency- resultSetConcurrencyresultSetHoldability- resultSetHoldability- Returns:
- prepared statement
- Throws:
java.sql.SQLException- if an error occurs- See Also:
Connection.prepareStatement(String, int, int, int)
-
serverPrepareStatement
public java.sql.PreparedStatement serverPrepareStatement(java.lang.String sql, int[] autoGenKeyIndexes) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionPrepares 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.- Specified by:
serverPrepareStatementin interfaceJdbcConnection- Parameters:
sql- statementautoGenKeyIndexes- autoGenKeyIndexes- Returns:
- prepared statement
- Throws:
java.sql.SQLException- if an error occurs- See Also:
Connection.prepareStatement(String, int[])
-
serverPrepareStatement
public java.sql.PreparedStatement serverPrepareStatement(java.lang.String sql, java.lang.String[] autoGenKeyColNames) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionPrepares 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.- Specified by:
serverPrepareStatementin interfaceJdbcConnection- Parameters:
sql- statementautoGenKeyColNames- autoGenKeyColNames- Returns:
- prepared statement
- Throws:
java.sql.SQLException- if an error occurs- See Also:
Connection.prepareStatement(String, String[])
-
setAutoCommit
public void setAutoCommit(boolean autoCommitFlag) throws java.sql.SQLException- Specified by:
setAutoCommitin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setCatalog
public void setCatalog(java.lang.String catalog) throws java.sql.SQLException- Specified by:
setCatalogin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setDatabase
public void setDatabase(java.lang.String db) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionSet current database for this connection.- Specified by:
setDatabasein interfaceJdbcConnection- Parameters:
db- the database for this connection to use- Throws:
java.sql.SQLException- if a database access error occurs
-
getDatabase
public java.lang.String getDatabase() throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionRetrieves this connection object's current database name.- Specified by:
getDatabasein interfaceJdbcConnection- Returns:
- current database name
- Throws:
java.sql.SQLException- if an error occurs
-
setFailedOver
public void setFailedOver(boolean flag)- Specified by:
setFailedOverin interfaceJdbcConnection- Parameters:
flag- The failedOver flag to set.
-
setHoldability
public void setHoldability(int arg0) throws java.sql.SQLException- Specified by:
setHoldabilityin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setInGlobalTx
public void setInGlobalTx(boolean flag)Description copied from interface:JdbcConnectionSet the state of being in a global (XA) transaction.- Specified by:
setInGlobalTxin interfaceJdbcConnection- Parameters:
flag- the state flag
-
setReadOnly
public void setReadOnly(boolean readOnlyFlag) throws java.sql.SQLException- Specified by:
setReadOnlyin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setReadOnlyInternal
public void setReadOnlyInternal(boolean readOnlyFlag) throws java.sql.SQLException- Specified by:
setReadOnlyInternalin interfaceJdbcConnection- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint() throws java.sql.SQLException- Specified by:
setSavepointin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException- Specified by:
setSavepointin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws java.sql.SQLException- Specified by:
setTransactionIsolationin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setTypeMap
public void setTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> map) throws java.sql.SQLException- Specified by:
setTypeMapin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
shutdownServer
public void shutdownServer() throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionUsed by MiniAdmin to shutdown a MySQL server- Specified by:
shutdownServerin interfaceJdbcConnection- Throws:
java.sql.SQLException- if the command can not be issued.
-
unregisterStatement
Description copied from interface:JdbcConnectionRemove the given statement from the list of open statements- Specified by:
unregisterStatementin interfaceJdbcConnection- Parameters:
stmt- the Statement instance to remove
-
versionMeetsMinimum
public boolean versionMeetsMinimum(int major, int minor, int subminor) -
getCachedMetaData
Description copied from interface:JdbcConnectionReturns 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.- Specified by:
getCachedMetaDatain interfaceJdbcConnection- Parameters:
sql- the query that is the key to the cache- Returns:
- metadata cached for the given SQL, or none if it doesn't exist.
-
initializeResultsMetadataFromCache
public void initializeResultsMetadataFromCache(java.lang.String sql, CachedResultSetMetaData cachedMetaData, ResultSetInternalMethods resultSet) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionCaches 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.- Specified by:
initializeResultsMetadataFromCachein interfaceJdbcConnection- Parameters:
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.- Throws:
java.sql.SQLException- if an error occurs
-
getStatementComment
public java.lang.String getStatementComment()Description copied from interface:JdbcConnectionReturns the comment that will be prepended to all statements sent to the server.- Specified by:
getStatementCommentin interfaceJdbcConnection- Returns:
- the comment that will be prepended to all statements sent to the server.
-
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- Parameters:
comment- the comment that will be prepended to all statements sent to the server.
-
transactionBegun
public void transactionBegun()- Specified by:
transactionBegunin interfaceTransactionEventHandler
-
transactionCompleted
public void transactionCompleted()- Specified by:
transactionCompletedin interfaceTransactionEventHandler
-
storesLowerCaseTableName
public boolean storesLowerCaseTableName()- Specified by:
storesLowerCaseTableNamein interfaceJdbcConnection
-
getExceptionInterceptor
- Specified by:
getExceptionInterceptorin interfaceMysqlConnection
-
isServerLocal
public boolean isServerLocal() throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionIs the server this connection is connected to "local" (i.e. same host) as the application?- Specified by:
isServerLocalin interfaceJdbcConnection- Returns:
- true if the server is "local"
- Throws:
java.sql.SQLException- if an error occurs
-
getSessionMaxRows
public int getSessionMaxRows()Description copied from interface:JdbcConnectionReturns the sql select limit max-rows for this session.- Specified by:
getSessionMaxRowsin interfaceJdbcConnection- Returns:
- int max rows
-
setSessionMaxRows
public void setSessionMaxRows(int max) throws java.sql.SQLExceptionDescription copied from interface:JdbcConnectionSets the sql select limit max-rows for this session if different from current.- Specified by:
setSessionMaxRowsin interfaceJdbcConnection- Parameters:
max- the new max-rows value to set.- Throws:
java.sql.SQLException- if a database error occurs issuing the statement that sets the limit.
-
setSchema
public void setSchema(java.lang.String schema) throws java.sql.SQLException- Specified by:
setSchemain interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getSchema
public java.lang.String getSchema() throws java.sql.SQLException- Specified by:
getSchemain interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
abort
public void abort(java.util.concurrent.Executor executor) throws java.sql.SQLException- Specified by:
abortin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setNetworkTimeout
public void setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds) throws java.sql.SQLException- Specified by:
setNetworkTimeoutin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws java.sql.SQLException- Specified by:
getNetworkTimeoutin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createClob
public java.sql.Clob createClob()- Specified by:
createClobin interfacejava.sql.Connection
-
createBlob
public java.sql.Blob createBlob()- Specified by:
createBlobin interfacejava.sql.Connection
-
createNClob
public java.sql.NClob createNClob()- Specified by:
createNClobin interfacejava.sql.Connection
-
createSQLXML
public java.sql.SQLXML createSQLXML() throws java.sql.SQLException- Specified by:
createSQLXMLin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
isValid
public boolean isValid(int timeout) throws java.sql.SQLException- Specified by:
isValidin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getClientInfoProviderImpl
- Specified by:
getClientInfoProviderImplin interfaceJdbcConnection- Throws:
java.sql.SQLException
-
setClientInfo
public void setClientInfo(java.lang.String name, java.lang.String value) throws java.sql.SQLClientInfoException- Specified by:
setClientInfoin interfacejava.sql.Connection- Throws:
java.sql.SQLClientInfoException
-
setClientInfo
public void setClientInfo(java.util.Properties properties) throws java.sql.SQLClientInfoException- Specified by:
setClientInfoin interfacejava.sql.Connection- Throws:
java.sql.SQLClientInfoException
-
getClientInfo
public java.lang.String getClientInfo(java.lang.String name) throws java.sql.SQLException- Specified by:
getClientInfoin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getClientInfo
public java.util.Properties getClientInfo() throws java.sql.SQLException- Specified by:
getClientInfoin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createArrayOf
public java.sql.Array createArrayOf(java.lang.String typeName, java.lang.Object[] elements) throws java.sql.SQLException- Specified by:
createArrayOfin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createStruct
public java.sql.Struct createStruct(java.lang.String typeName, java.lang.Object[] attributes) throws java.sql.SQLException- Specified by:
createStructin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException- Specified by:
unwrapin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException- Specified by:
isWrapperForin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
getSession
- Specified by:
getSessionin interfaceMysqlConnection
-
getHostPortPair
public java.lang.String getHostPortPair()- Specified by:
getHostPortPairin interfaceJdbcConnection
-
handleNormalClose
public void handleNormalClose()- Specified by:
handleNormalClosein interfaceSession.SessionEventListener
-
handleReconnect
public void handleReconnect()- Specified by:
handleReconnectin interfaceSession.SessionEventListener
-
handleCleanup
public void handleCleanup(java.lang.Throwable whyCleanedUp)- Specified by:
handleCleanupin interfaceSession.SessionEventListener
-