Interface Connection

All Superinterfaces:
AutoCloseable, Connection, ConnectionProperties, Wrapper
All Known Subinterfaces:
JDBC4MySQLConnection, LoadBalancedConnection, MySQLConnection, ReplicationConnection
All Known Implementing Classes:
ConnectionImpl, JDBC4Connection, JDBC4LoadBalancedMySQLConnection, JDBC4MultiHostMySQLConnection, JDBC4ReplicationMySQLConnection, LoadBalancedMySQLConnection, MultiHostMySQLConnection, ReplicationMySQLConnection

public interface Connection extends Connection, ConnectionProperties
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).
  • Method Details

    • 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 will remain under the context of the current user.
      Parameters:
      userName - the username to authenticate with
      newPassword - the password to authenticate with
      Throws:
      SQLException - if authentication fails, or some other error occurs while performing the command.
    • clearHasTriedMaster

      @Deprecated void clearHasTriedMaster()
      Deprecated.
    • 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.
      Throws:
      SQLException
      See Also:
    • 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.
      Throws:
      SQLException
      See Also:
    • 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.
      Throws:
      SQLException
      See Also:
    • 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.
      Throws:
      SQLException
      See Also:
    • 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.
      Throws:
      SQLException
      See Also:
    • 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.
      Throws:
      SQLException
      See Also:
    • getActiveStatementCount

      int getActiveStatementCount()
      Returns the number of statements active on this connection, which haven't been .close()d.
    • getIdleFor

      long getIdleFor()
      Reports how long this connection has been idle. This time (reported in milliseconds) is updated once a query has completed.
      Returns:
      number of ms that this connection has been idle, 0 if the driver is busy retrieving results.
    • getLog

      com.mysql.jdbc.log.Log getLog() throws SQLException
      Returns the log mechanism that should be used to log information from/for this Connection.
      Returns:
      the Log instance to use for logging messages.
      Throws:
      SQLException - if an error occurs
    • getServerCharacterEncoding

      @Deprecated String getServerCharacterEncoding()
      Deprecated.
      replaced by Connection.getServerCharset()
      Returns the server's character set
      Returns:
      the server's character set.
    • getServerCharset

      String getServerCharset()
      Returns the server's character set
      Returns:
      the server's character set.
    • getServerTimezoneTZ

      TimeZone getServerTimezoneTZ()
      Returns the TimeZone that represents the configured timezone for the server.
    • getStatementComment

      String getStatementComment()
      Returns the comment that will be prepended to all statements sent to the server.
      Returns:
      the comment that will be prepended to all statements sent to the server.
    • hasTriedMaster

      @Deprecated boolean hasTriedMaster()
      Deprecated.
      Has this connection tried to execute a query on the "master" server (first host in a multiple host list).
    • isInGlobalTx

      boolean isInGlobalTx()
      Is this connection currently a participant in an XA transaction?
    • setInGlobalTx

      void setInGlobalTx(boolean flag)
      Set the state of being in a global (XA) transaction.
      Parameters:
      flag -
    • isMasterConnection

      boolean isMasterConnection()
      Is this connection connected to the first host in the list if there is a list of servers in the URL?
      Returns:
      true if this connection is connected to the first in the list.
    • isNoBackslashEscapesSet

      boolean isNoBackslashEscapesSet()
      Is the server in a sql_mode that doesn't allow us to use \\ to escape things?
      Returns:
      Returns the noBackslashEscapes.
    • isSameResource

      boolean isSameResource(Connection c)
      Does this connection have the same resource name as the given connection (for XA)?
      Parameters:
      c -
    • lowerCaseTableNames

      boolean lowerCaseTableNames()
      Is the server configured to use lower-case table names only?
      Returns:
      true if lower_case_table_names is 'on'
    • parserKnowsUnicode

      boolean parserKnowsUnicode()
      Does the server this connection is connected to support unicode?
    • ping

      void ping() throws SQLException
      Detect if the connection is still good by sending a ping command to the server.
      Throws:
      SQLException - if the ping fails
    • resetServerState

      void resetServerState() throws SQLException
      Resets the server-side state of this connection. Doesn't work for MySQL versions older than 4.0.6 or if isParanoid() is set (it will become a no-op in these cases). Usually only used from connection pooling code.
      Throws:
      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.
      Throws:
      SQLException
      See Also:
    • 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.
      Throws:
      SQLException
      See Also:
    • 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.
      Throws:
      SQLException
      See Also:
    • 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.
      Throws:
      SQLException
      See Also:
    • 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.
      Throws:
      SQLException
      See Also:
    • 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.
      Throws:
      SQLException
      See Also:
    • setFailedOver

      void setFailedOver(boolean flag)
      Parameters:
      failedOver - The failedOver to set.
    • setPreferSlaveDuringFailover

      @Deprecated void setPreferSlaveDuringFailover(boolean flag)
      Deprecated.
      Parameters:
      preferSlaveDuringFailover - The preferSlaveDuringFailover 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.
      Parameters:
      comment - the comment that will be prepended to all statements sent to the server.
    • shutdownServer

      void shutdownServer() throws SQLException
      Used by MiniAdmin to shutdown a MySQL server
      Throws:
      SQLException - if the command can not be issued.
    • supportsIsolationLevel

      boolean supportsIsolationLevel()
      Does the server this connection is connected to support isolation levels?
    • supportsQuotedIdentifiers

      boolean supportsQuotedIdentifiers()
      Does the server this connection is connected to support quoted identifiers?
    • supportsTransactions

      boolean supportsTransactions()
      Does the server this connection is connected to support transactions?
    • versionMeetsMinimum

      boolean versionMeetsMinimum(int major, int minor, int subminor) throws SQLException
      Does the server this connection is connected to meet or exceed the given version?
      Throws:
      SQLException
    • reportQueryTime

      void reportQueryTime(long millisOrNanos)
    • isAbonormallyLongQuery

      boolean isAbonormallyLongQuery(long millisOrNanos)
    • initializeExtension

      void initializeExtension(Extension ex) throws SQLException
      Throws:
      SQLException
    • getAutoIncrementIncrement

      int getAutoIncrementIncrement()
      Returns the -session- value of 'auto_increment_increment' from the server if it exists, or '1' if not.
    • hasSameProperties

      boolean hasSameProperties(Connection c)
      Does this connection have the same properties as another?
    • getProperties

      Properties getProperties()
      Returns the parsed and passed in properties for this connection.
    • getHost

      String getHost()
    • setProxy

      void setProxy(MySQLConnection proxy)
    • isServerLocal

      boolean isServerLocal() throws SQLException
      Is the server this connection is connected to "local" (i.e. same host) as the application?
      Throws:
      SQLException
    • getSessionMaxRows

      int getSessionMaxRows()
    • setSessionMaxRows

      void setSessionMaxRows(int max) throws SQLException
      Throws:
      SQLException
    • setSchema

      void setSchema(String schema) throws SQLException
      Specified by:
      setSchema in interface Connection
      Throws:
      SQLException
    • getSchema

      String getSchema() throws SQLException
      Specified by:
      getSchema in interface Connection
      Throws:
      SQLException
    • abort

      void abort(Executor executor) throws SQLException
      Specified by:
      abort in interface Connection
      Throws:
      SQLException
    • setNetworkTimeout

      void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
      Specified by:
      setNetworkTimeout in interface Connection
      Throws:
      SQLException
    • getNetworkTimeout

      int getNetworkTimeout() throws SQLException
      Specified by:
      getNetworkTimeout in interface Connection
      Throws:
      SQLException
    • abortInternal

      void abortInternal() throws SQLException
      Throws:
      SQLException
    • checkClosed

      void checkClosed() throws SQLException
      Throws:
      SQLException
    • getConnectionMutex

      Object getConnectionMutex()