接口 JdbcConnection

    • 方法详细资料

      • 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 with
        newPassword - 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 - statement
        autoGenKeyIndex - 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 - statement
        resultSetType - resultSetType
        resultSetConcurrency - 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 - statement
        autoGenKeyIndexes - 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 - statement
        resultSetType - resultSetType
        resultSetConcurrency - resultSetConcurrency
        resultSetHoldability - 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 - statement
        autoGenKeyColNames - 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()
        已过时。
        返回:
        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 SQLException
        Resets 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 - statement
        autoGenKeyIndex - 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 - statement
        resultSetType - resultSetType
        resultSetConcurrency - 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 - statement
        resultSetType - resultSetType
        resultSetConcurrency - resultSetConcurrency
        resultSetHoldability - 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 - statement
        autoGenKeyIndexes - 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 - statement
        autoGenKeyColNames - 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 SQLException
        Used 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
      • getHostPortPair

        String getHostPortPair()
      • isServerLocal

        boolean isServerLocal()
                       throws SQLException
        Is 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 SQLException
        Sets 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 SQLException
        Clobbers 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.
      • 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
      • isReadOnly

        boolean isReadOnly​(boolean useSessionStatus)
                    throws SQLException
        Tests 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 SQLException
        Closes 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 performed
        reason - the exception caused this method call
        抛出:
        SQLException - if an error occurs
      • registerStatement

        void registerStatement​(JdbcStatement stmt)
        Register a Statement instance as open.
        参数:
        stmt - the Statement instance to remove
      • storesLowerCaseTableName

        boolean storesLowerCaseTableName()
      • unregisterStatement

        void unregisterStatement​(JdbcStatement stmt)
        Remove the given statement from the list of open statements
        参数:
        stmt - the Statement instance to remove
      • 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