public class AbstractQueryProtocol extends AbstractConnectProtocol implements Protocol
| 限定符和类型 | 字段和说明 |
|---|---|
protected static Logger |
lockLogger |
activeStreamingResult, autoCommit, autoIncrementIncrement, CHECK_GALERA_STATE_QUERY, connected, database, enableFullLinkTrace, eofDeprecated, exceptionFactory, explicitClosed, galeraAllowedStates, hasWarnings, lock, options, proxy, reader, readOnly, seed, serverCapabilities, serverPrepareStatementCache, serverStatus, serverThreadId, serverVersion, socket, socketTimeout, traceCache, transactionIsolationLevel, urlParser, useNewExtraInfo, useOceanBaseProtocolV20, username, writer| 限定符和类型 | 方法和说明 |
|---|---|
ServerPrepareResult |
addPrepareInCache(String key,
ServerPrepareResult serverPrepareResult) |
void |
cancelCurrentQuery()
Cancels the current query - clones the current protocol and executes a query using the new
connection.
|
void |
changeUser(String user,
String pwd) |
void |
clearNetworkStatistics() |
void |
closeExplicit() |
boolean |
executeBatchClient(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult prepareResult,
List<ParameterHolder[]> parametersList,
boolean hasLongData)
Execute clientPrepareQuery batch.
|
ServerPrepareResult |
executeBatchServer(ServerPrepareResult serverPrepareResult,
Results results,
String sql,
List<ParameterHolder[]> parametersList,
boolean hasLongData)
Execute Prepare if needed, and execute COM_STMT_EXECUTE queries in batch.
|
void |
executeBatchStmt(boolean mustExecuteOnMaster,
Results results,
List<String> queries)
Execute batch from Statement.executeBatch().
|
void |
executePreparedQuery(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
ParameterHolder[] parameters)
Execute a query that is already prepared.
|
ServerPrepareResult |
executePreparedQuery(int parameterCount,
ParameterHolder[] parameters,
ServerPrepareResult serverPrepareResult,
Results results)
Execute a query that is to be prepared on server in Oracle mode
|
void |
executePreparedQueryArrayBinding(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
List<ParameterHolder[]> queryParameters,
int queryParameterSize)
Protocol processing mechanism when prepareExecute is not used
|
ServerPrepareResult |
executePreparedQueryArrayBinding(int parameterCount,
boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
List<ParameterHolder[]> queryParameters,
int queryParamtersSize)
Protocol processing mechanism when prepareExecute is used.
|
void |
executeQuery(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
ParameterHolder[] parameters)
Execute a unique clientPrepareQuery.
|
void |
executeQuery(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
ParameterHolder[] parameters,
int queryTimeout)
Execute a unique clientPrepareQuery.
|
void |
executeQuery(boolean mustExecuteOnMaster,
Results results,
String sql)
Execute query directly to outputStream.
|
void |
executeQuery(boolean mustExecuteOnMaster,
Results results,
String sql,
Charset charset) |
void |
executeQuery(String sql)
Execute internal query.
|
ColumnDefinition[] |
fetchRowViaCursor(int cursorId,
int fetchSize,
Results results) |
ColumnDefinition[] |
fetchRowViaCursorForOracle(int cursorId,
int numRows,
byte offsetType,
int offset,
Results results) |
boolean |
forceReleasePrepareStatement(int statementId)
Force release of prepare statement that are not used.
|
boolean |
getAutocommit()
Get current autocommit status.
|
int |
getAutoIncrementIncrement()
Get current auto increment increment. *** no lock needed ****
|
String |
getCatalog() |
long |
getChecksum() |
int |
getExecuteMode() |
int |
getIterationCount() |
long |
getLastPacketCostTime() |
long |
getLastPacketResponseTimestamp() |
long |
getLastPacketSendTimestamp() |
long |
getMaxRows() |
boolean |
getNetworkStatisticsFlag() |
void |
getResult(Results results) |
ColumnDefinition[] |
getResultWithoutValue(Results results) |
int |
getTimeout()
Returns the connection timeout in milliseconds.
|
int |
getTransactionIsolationLevel() |
SQLException |
handleIoException(Exception initialException)
Handle IoException (reconnect if Exception is due to having send too much data, making server
close the connection.
|
void |
interrupt() |
boolean |
inTransaction() |
boolean |
isInterrupted() |
boolean |
isValid(int timeout)
Check that connection is valid. !!
|
boolean |
ping() |
ServerPrepareResult |
prepare(String sql,
boolean executeOnMaster)
Prepare query on server side.
|
void |
prolog(long maxRows,
boolean hasProxy,
OceanBaseConnection connection,
OceanBaseStatement statement)
Preparation before command.
|
void |
prologProxy(ServerPrepareResult serverPrepareResult,
long maxRows,
boolean hasProxy,
OceanBaseConnection connection,
OceanBaseStatement statement) |
SQLException |
readErrorPacket(Buffer buffer,
Results results)
Read ERR_Packet.
|
void |
readOkPacket(Buffer buffer,
Results results)
Read OK_Packet.
|
void |
readResultSet(ColumnDefinition[] ci,
Results results)
Read ResultSet Packet.
|
void |
releasePrepareStatement(ServerPrepareResult serverPrepareResult)
Deallocate prepare statement if not used anymore.
|
void |
reset()
Reset connection state.
|
void |
resetChecksum() |
void |
resetDatabase() |
void |
resetStateAfterFailover(long maxRows,
int transactionIsolationLevel,
String database,
boolean autocommit)
Set current state after a failover.
|
void |
rollback()
Rollback transaction.
|
void |
setActiveFutureTask(FutureTask activeFutureTask) |
void |
setAutoCommit(boolean autoCommit) |
void |
setCatalog(String database) |
void |
setChecksum(long checksum) |
void |
setComStmtPrepareExecuteField(int iterationCount,
int executeMode,
long checksum) |
void |
setExecuteMode(int executeMode) |
void |
setIterationCount(int iterationCount) |
void |
setLocalInfileInputStream(InputStream inputStream) |
void |
setMaxRows(long max) |
void |
setNetworkStatisticsFlag(boolean flag) |
void |
setReadonly(boolean readOnly)
Puts this connection in read-only / read-write mode
|
void |
setTimeout(int timeout)
Sets the connection timeout.
|
void |
setTransactionIsolation(int level)
Set transaction isolation.
|
void |
setUsername(String username) |
void |
stopIfInterrupted()
Throw TimeoutException if timeout has been reached.
|
abort, changeSocketSoTimeout, changeSocketTcpNoDelay, checkIfMaster, cleanMemory, close, connect, connectWithoutProxy, destroySocket, endCallInterface, getActiveStreamingResult, getCurrentHost, getDatabase, getEncoding, getFullLinkTraceAction, getFullLinkTraceClientInfo, getFullLinkTraceIdentifier, getFullLinkTraceLevel, getFullLinkTraceModule, getFullLinkTracePrintSamplePercentage, getFullLinkTraceRecordPolicy, getFullLinkTraceSamplePercentage, getFullLinkTraceSlowQueryThreshold, getHost, getHostAddress, getLock, getMajorServerVersion, getMinorServerVersion, getObServerVersion, getOptions, getPinGlobalTxToPhysicalConnection, getPort, getProxy, getReader, getReadonly, getServerStatus, getServerThreadId, getServerTimeZone, getServerVersion, getSocket, getTimeTrace, getTimeZone, getTraces, getUrlParser, getUsername, getWriter, hasMoreResults, hasWarnings, haveInformationSchemaParameters, isClosed, isConnected, isEofDeprecated, isExplicitClosed, isMasterConnection, isOracleMode, isServerMariaDb, isTZTablesImported, mustBeMasterConnection, noBackslashEscapes, parseVersion, postConnectionQueries, prepareStatementCache, readEofPacket, readPipelineCheckMaster, removeActiveStreamingResult, removeHasMoreResults, sessionStateAware, setActiveStreamingResult, setFullLinkTraceAction, setFullLinkTraceClientInfo, setFullLinkTraceIdentifier, setFullLinkTraceModule, setHasWarnings, setHostAddress, setHostFailedWithoutProxy, setObServerVersion, setOracleMode, setProxy, setServerStatus, shouldReconnectWithoutProxy, skip, skipEofPacket, startCallInterface, supportFetchWithOffset, supportStmtPrepareExecute, versionGreaterOrEqual, whyConnectedIsFalseclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitabort, changeSocketSoTimeout, changeSocketTcpNoDelay, checkIfMaster, close, connect, connectWithoutProxy, endCallInterface, getActiveStreamingResult, getCurrentHost, getDatabase, getEncoding, getFullLinkTraceAction, getFullLinkTraceClientInfo, getFullLinkTraceIdentifier, getFullLinkTraceLevel, getFullLinkTraceModule, getFullLinkTracePrintSamplePercentage, getFullLinkTraceRecordPolicy, getFullLinkTraceSamplePercentage, getFullLinkTraceSlowQueryThreshold, getHost, getHostAddress, getLock, getMajorServerVersion, getMinorServerVersion, getObServerVersion, getOptions, getPinGlobalTxToPhysicalConnection, getPort, getProxy, getReader, getReadonly, getServerStatus, getServerThreadId, getServerVersion, getSocket, getTimeTrace, getTimeZone, getTraces, getUrlParser, getUsername, getWriter, hasMoreResults, hasWarnings, haveInformationSchemaParameters, isClosed, isConnected, isEofDeprecated, isExplicitClosed, isMasterConnection, isOracleMode, isServerMariaDb, isTZTablesImported, mustBeMasterConnection, noBackslashEscapes, parseVersion, prepareStatementCache, readEofPacket, removeActiveStreamingResult, removeHasMoreResults, sessionStateAware, setActiveStreamingResult, setFullLinkTraceAction, setFullLinkTraceClientInfo, setFullLinkTraceIdentifier, setFullLinkTraceModule, setHasWarnings, setHostAddress, setHostFailedWithoutProxy, setObServerVersion, setProxy, setServerStatus, shouldReconnectWithoutProxy, skip, skipEofPacket, startCallInterface, supportFetchWithOffset, supportStmtPrepareExecute, versionGreaterOrEqualprotected static final Logger lockLogger
public void reset()
throws SQLException
reset 在接口中 ProtocolSQLException - if command failedpublic ServerPrepareResult prepare(String sql, boolean executeOnMaster) throws SQLException
For failover, two additional information are in the result-set object : - current connection : Since server maintain a state of this prepare statement, all query will be executed on this particular connection. - executeOnMaster : state of current connection when creating this prepareStatement (if was on master, will only be executed on master. If was on a slave, can be execute temporary on master, but we keep this flag, so when a slave is connected back to relaunch this query on slave)
prepare 在接口中 Protocolsql - the queryexecuteOnMaster - state of current connection when creating this prepareStatementSQLException - if any error occur on connection.public void executeQuery(String sql) throws SQLException
!! will not support multi values queries !!
executeQuery 在接口中 ProtocolexecuteQuery 在类中 AbstractConnectProtocolsql - sqlSQLException - in any exception occurpublic void executeQuery(boolean mustExecuteOnMaster,
Results results,
String sql)
throws SQLException
executeQuery 在接口中 ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsql - the query to executeInternalSQLException - exceptionpublic void executeQuery(boolean mustExecuteOnMaster,
Results results,
String sql,
Charset charset)
throws SQLException
executeQuery 在接口中 ProtocolSQLExceptionpublic void executeQuery(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
ParameterHolder[] parameters)
throws SQLException
executeQuery 在接口中 ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsclientPrepareResult - clientPrepareResultparameters - parametersSQLException - exceptionpublic void executeQuery(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
ParameterHolder[] parameters,
int queryTimeout)
throws SQLException
executeQuery 在接口中 ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsclientPrepareResult - clientPrepareResultparameters - parametersqueryTimeout - if timeout is set and must use max_statement_timeSQLException - exceptionpublic void executePreparedQuery(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
ParameterHolder[] parameters)
throws SQLException
executePreparedQuery 在接口中 ProtocolmustExecuteOnMaster - must execute on masterserverPrepareResult - prepare resultresults - execution resultparameters - parametersSQLException - exceptionpublic ServerPrepareResult executePreparedQuery(int parameterCount, ParameterHolder[] parameters, ServerPrepareResult serverPrepareResult, Results results) throws SQLException
executePreparedQuery 在接口中 ProtocolSQLException - exceptionpublic boolean executeBatchClient(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult prepareResult,
List<ParameterHolder[]> parametersList,
boolean hasLongData)
throws SQLException
executeBatchClient 在接口中 ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsprepareResult - ClientPrepareResultparametersList - List of parametershasLongData - has parameter with long data (stream)SQLException - exceptionpublic void executeBatchStmt(boolean mustExecuteOnMaster,
Results results,
List<String> queries)
throws SQLException
executeBatchStmt 在接口中 ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsqueries - queriesSQLException - if any exception occurpublic ServerPrepareResult executeBatchServer(ServerPrepareResult serverPrepareResult, Results results, String sql, List<ParameterHolder[]> parametersList, boolean hasLongData) throws SQLException
executeBatchServer 在接口中 ProtocolserverPrepareResult - prepare result. can be null if not prepared.results - execution resultssql - sql query if needed to be preparedparametersList - parameter listhasLongData - has long data (stream)SQLException - if parameter error or connection error occur.public ColumnDefinition[] fetchRowViaCursor(int cursorId, int fetchSize, Results results) throws SQLException
fetchRowViaCursor 在接口中 ProtocolSQLExceptionpublic ColumnDefinition[] fetchRowViaCursorForOracle(int cursorId, int numRows, byte offsetType, int offset, Results results) throws SQLException
fetchRowViaCursorForOracle 在接口中 ProtocolSQLExceptionpublic void executePreparedQueryArrayBinding(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
List<ParameterHolder[]> queryParameters,
int queryParameterSize)
throws SQLException
executePreparedQueryArrayBinding 在接口中 ProtocolmustExecuteOnMaster - serverPrepareResult - results - queryParameters - queryParameterSize - SQLExceptionpublic ServerPrepareResult executePreparedQueryArrayBinding(int parameterCount, boolean mustExecuteOnMaster, ServerPrepareResult serverPrepareResult, Results results, List<ParameterHolder[]> queryParameters, int queryParamtersSize) throws SQLException
executePreparedQueryArrayBinding 在接口中 ProtocolparameterCount - is count of parameters.mustExecuteOnMaster - serverPrepareResult - results - queryParameters - is sublist of parameters list.queryParamtersSize - SQLExceptionpublic long getLastPacketCostTime()
throws SQLException
getLastPacketCostTime 在接口中 ProtocolSQLExceptionpublic boolean getNetworkStatisticsFlag()
getNetworkStatisticsFlag 在接口中 Protocolpublic void setNetworkStatisticsFlag(boolean flag)
setNetworkStatisticsFlag 在接口中 Protocolpublic long getLastPacketResponseTimestamp()
getLastPacketResponseTimestamp 在接口中 Protocolpublic long getLastPacketSendTimestamp()
getLastPacketSendTimestamp 在接口中 Protocolpublic void clearNetworkStatistics()
clearNetworkStatistics 在接口中 Protocolpublic void changeUser(String user, String pwd) throws SQLException
changeUser 在接口中 ProtocolSQLExceptionpublic void rollback()
throws SQLException
rollback 在接口中 ProtocolSQLExceptionpublic void setUsername(String username)
setUsername 在接口中 Protocolpublic boolean forceReleasePrepareStatement(int statementId)
throws SQLException
forceReleasePrepareStatement 在接口中 ProtocolstatementId - prepared statement Id to remove.SQLException - if connection exception.public boolean ping()
throws SQLException
ping 在接口中 ProtocolSQLExceptionpublic boolean isValid(int timeout)
throws SQLException
isValid 在接口中 Protocoltimeout - timeout in millisecondsSQLException - if any error occurpublic String getCatalog() throws SQLException
getCatalog 在接口中 ProtocolSQLExceptionpublic void setCatalog(String database) throws SQLException
setCatalog 在接口中 ProtocolSQLExceptionpublic void resetDatabase()
throws SQLException
resetDatabase 在接口中 ProtocolSQLExceptionpublic void cancelCurrentQuery()
throws SQLException
cancelCurrentQuery 在接口中 ProtocolSQLException - never thrownpublic boolean getAutocommit()
getAutocommit 在接口中 Protocolpublic void setAutoCommit(boolean autoCommit)
throws SQLException
setAutoCommit 在接口中 ProtocolSQLExceptionpublic boolean inTransaction()
inTransaction 在接口中 Protocolpublic void closeExplicit()
closeExplicit 在接口中 Protocolpublic void releasePrepareStatement(ServerPrepareResult serverPrepareResult) throws SQLException
releasePrepareStatement 在接口中 ProtocolserverPrepareResult - allocation resultSQLException - if de-allocation failed.public long getMaxRows()
getMaxRows 在接口中 Protocolpublic void setMaxRows(long max)
throws SQLException
setMaxRows 在接口中 ProtocolSQLExceptionpublic void setLocalInfileInputStream(InputStream inputStream)
setLocalInfileInputStream 在接口中 Protocolpublic int getTimeout()
getTimeout 在接口中 Protocolpublic void setTimeout(int timeout)
throws SocketException
setTimeout 在接口中 Protocoltimeout - the timeout, in millisecondsSocketException - if there is an error in the underlying protocol, such as a TCP error.public void setReadonly(boolean readOnly)
throws SQLException
setReadonly 在接口中 ProtocolreadOnly - true enables read-only mode; false disables itSQLException - If socket error.public void setTransactionIsolation(int level)
throws SQLException
setTransactionIsolation 在接口中 Protocollevel - transaction level.SQLException - if transaction level is unknownpublic int getTransactionIsolationLevel()
getTransactionIsolationLevel 在接口中 Protocolpublic void getResult(Results results) throws SQLException
getResult 在接口中 ProtocolSQLExceptionpublic ColumnDefinition[] getResultWithoutValue(Results results) throws SQLException
SQLExceptionpublic int getAutoIncrementIncrement()
throws SQLException
getAutoIncrementIncrement 在接口中 ProtocolSQLException - if cannot retrieve auto increment valuepublic void readOkPacket(Buffer buffer, Results results)
readOkPacket 在接口中 Protocolbuffer - current bufferresults - result objectpublic SQLException readErrorPacket(Buffer buffer, Results results)
readErrorPacket 在接口中 Protocolbuffer - current bufferresults - result objectpublic void readResultSet(ColumnDefinition[] ci, Results results) throws SQLException
readResultSet 在接口中 Protocolresults - result objectSQLException - if sub-result connection failpublic void prologProxy(ServerPrepareResult serverPrepareResult, long maxRows, boolean hasProxy, OceanBaseConnection connection, OceanBaseStatement statement) throws SQLException
prologProxy 在接口中 ProtocolSQLExceptionpublic void prolog(long maxRows,
boolean hasProxy,
OceanBaseConnection connection,
OceanBaseStatement statement)
throws SQLException
prolog 在接口中 ProtocolmaxRows - query max rowshasProxy - has proxyconnection - current connectionstatement - current statementSQLException - if any error occur.public ServerPrepareResult addPrepareInCache(String key, ServerPrepareResult serverPrepareResult)
addPrepareInCache 在接口中 Protocolpublic void resetStateAfterFailover(long maxRows,
int transactionIsolationLevel,
String database,
boolean autocommit)
throws SQLException
resetStateAfterFailover 在接口中 ProtocolmaxRows - current Max rowstransactionIsolationLevel - current transactionIsolationLeveldatabase - current databaseautocommit - current autocommit stateSQLException - if any error occur.public SQLException handleIoException(Exception initialException)
There is 3 kind of IOException :
handleIoException 在接口中 ProtocolinitialException - initial Io errorpublic void setActiveFutureTask(FutureTask activeFutureTask)
setActiveFutureTask 在接口中 Protocolpublic boolean isInterrupted()
isInterrupted 在接口中 Protocolpublic void stopIfInterrupted()
throws SQLTimeoutException
stopIfInterrupted 在接口中 ProtocolSQLTimeoutException - to indicate timeout exception.public long getChecksum()
getChecksum 在接口中 Protocolpublic void setChecksum(long checksum)
setChecksum 在接口中 Protocolpublic void resetChecksum()
resetChecksum 在接口中 Protocolpublic int getIterationCount()
getIterationCount 在接口中 Protocolpublic void setIterationCount(int iterationCount)
setIterationCount 在接口中 Protocolpublic int getExecuteMode()
getExecuteMode 在接口中 Protocolpublic void setExecuteMode(int executeMode)
setExecuteMode 在接口中 Protocolpublic void setComStmtPrepareExecuteField(int iterationCount,
int executeMode,
long checksum)
setComStmtPrepareExecuteField 在接口中 ProtocolCopyright © 2024 oceanbase.com. All rights reserved.