|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mariadb.jdbc.internal.protocol.AbstractConnectProtocol
org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol
public class AbstractQueryProtocol
Field Summary | |
---|---|
static ThreadPoolExecutor |
readScheduler
|
Fields inherited from class org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol |
---|
activeStreamingResult, autoIncrementIncrement, connected, currentHost, database, dataTypeMappingFlags, eofDeprecated, explicitClosed, hasWarnings, IS_MASTER_QUERY, lock, options, proxy, reader, readOnly, serverCapabilities, serverPrepareStatementCache, serverStatus, serverThreadId, SESSION_QUERY, socket, urlParser, writer |
Constructor Summary | |
---|---|
AbstractQueryProtocol(UrlParser urlParser,
ReentrantLock lock)
Get a protocol instance. |
Method Summary | |
---|---|
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 |
closeExplicit()
|
void |
executeBatch(boolean mustExecuteOnMaster,
Results results,
List<String> queries)
Execute list of queries not rewritable. |
void |
executeBatchMulti(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
List<ParameterHolder[]> parametersList)
Execute clientPrepareQuery batch. |
void |
executeBatchMultiple(boolean mustExecuteOnMaster,
Results results,
List<String> queries)
Execute list of queries. |
void |
executeBatchRewrite(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult prepareResult,
List<ParameterHolder[]> parameterList,
boolean rewriteValues)
Specific execution for batch rewrite that has specific query for memory. |
void |
executePreparedQuery(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
ParameterHolder[] parameters)
Execute a query that is already prepared. |
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. |
boolean |
forceReleasePrepareStatement(int statementId)
Force release of prepare statement that are not used. |
void |
forceReleaseWaitingPrepareStatement()
Force release of prepare statement that are not used. |
boolean |
getAutocommit()
Get current autocommit status. |
int |
getAutoIncrementIncrement()
Get current auto increment increment. |
long |
getMaxRows()
|
void |
getResult(Results results)
|
int |
getTimeout()
Returns the connection timeout in milliseconds. |
int |
getTransactionIsolationLevel()
|
SQLException |
handleIoException(IOException initialException)
Handle IoException (reconnect if Exception is due to having send too much data, making server close the connection. |
boolean |
inTransaction()
|
boolean |
isInterrupted()
|
boolean |
isValid()
|
boolean |
ping()
|
ServerPrepareResult |
prepare(String sql,
boolean executeOnMaster)
Prepare query on server side. |
ServerPrepareResult |
prepareAndExecute(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
String sql,
ParameterHolder[] parameters)
Execute Prepare if needed, and execute COM_STMT_EXECUTE queries in batch. |
ServerPrepareResult |
prepareAndExecutes(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
String sql,
List<ParameterHolder[]> parametersList)
Execute Prepare if needed, and execute COM_STMT_EXECUTE queries in batch. |
void |
prolog(long maxRows,
boolean hasProxy,
MariaDbConnection connection,
MariaDbStatement statement)
Preparation before command. |
void |
prologProxy(ServerPrepareResult serverPrepareResult,
long maxRows,
boolean hasProxy,
MariaDbConnection connection,
MariaDbStatement statement)
|
SQLException |
readErrorPacket(Buffer buffer,
Results results)
Read ERR_Packet. |
void |
readLocalInfilePacket(Buffer buffer,
Results results)
Read Local_infile Packet. |
void |
readOkPacket(Buffer buffer,
Results results)
Read OK_Packet. |
void |
readPacket(Results results)
Read server response packet. |
void |
readResultSet(Buffer buffer,
Results results)
Read ResultSet Packet. |
void |
releasePrepareStatement(ServerPrepareResult serverPrepareResult)
Deallocate prepare statement if not used anymore. |
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 |
setCatalog(String database)
|
void |
setInternalMaxRows(long max)
Set max row retuen by a statement. |
void |
setLocalInfileInputStream(InputStream inputStream)
|
void |
setMaxRows(long max)
|
void |
setTimeout(int timeout)
Sets the connection timeout. |
void |
setTransactionIsolation(int level)
Set transaction isolation. |
void |
stopIfInterrupted()
Throw TimeoutException if timeout has been reached. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static ThreadPoolExecutor readScheduler
Constructor Detail |
---|
public AbstractQueryProtocol(UrlParser urlParser, ReentrantLock lock)
urlParser
- connection URL infoslock
- the lock for thread synchronisationMethod Detail |
---|
public void executeQuery(String sql) throws SQLException
!! will not support multi values queries !!
executeQuery
in interface Protocol
executeQuery
in class AbstractConnectProtocol
sql
- sql
SQLException
- in any exception occurpublic void executeQuery(boolean mustExecuteOnMaster, Results results, String sql) throws SQLException
executeQuery
in interface Protocol
mustExecuteOnMaster
- was intended to be launched on master connectionresults
- resultsql
- the query to executeInternal
SQLException
- exceptionpublic void executeQuery(boolean mustExecuteOnMaster, Results results, String sql, Charset charset) throws SQLException
executeQuery
in interface Protocol
SQLException
public void executeQuery(boolean mustExecuteOnMaster, Results results, ClientPrepareResult clientPrepareResult, ParameterHolder[] parameters) throws SQLException
executeQuery
in interface Protocol
mustExecuteOnMaster
- was intended to be launched on master connectionresults
- resultsclientPrepareResult
- clientPrepareResultparameters
- parameters
SQLException
- exceptionpublic void executeQuery(boolean mustExecuteOnMaster, Results results, ClientPrepareResult clientPrepareResult, ParameterHolder[] parameters, int queryTimeout) throws SQLException
executeQuery
in interface Protocol
mustExecuteOnMaster
- was intended to be launched on master connectionresults
- resultsclientPrepareResult
- clientPrepareResultparameters
- parametersqueryTimeout
- if timeout is set and must use max_statement_time
SQLException
- exceptionpublic void executeBatchMulti(boolean mustExecuteOnMaster, Results results, ClientPrepareResult clientPrepareResult, List<ParameterHolder[]> parametersList) throws SQLException
executeBatchMulti
in interface Protocol
mustExecuteOnMaster
- was intended to be launched on master connectionresults
- resultsclientPrepareResult
- ClientPrepareResultparametersList
- List of parameters
SQLException
- exceptionpublic void executeBatch(boolean mustExecuteOnMaster, Results results, List<String> queries) throws SQLException
executeBatch
in interface Protocol
mustExecuteOnMaster
- was intended to be launched on master connectionresults
- result objectqueries
- list of queries
SQLException
- exceptionpublic ServerPrepareResult prepare(String sql, boolean executeOnMaster) throws SQLException
For failover, two additional information are in the resultset 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
in interface Protocol
sql
- the queryexecuteOnMaster
- state of current connection when creating this prepareStatement
SQLException
- if any error occur on connection.public void executeBatchMultiple(boolean mustExecuteOnMaster, Results results, List<String> queries) throws SQLException
executeBatchMultiple
in interface Protocol
mustExecuteOnMaster
- was intended to be launched on master connectionresults
- result objectqueries
- list of queries
SQLException
- exceptionpublic void executeBatchRewrite(boolean mustExecuteOnMaster, Results results, ClientPrepareResult prepareResult, List<ParameterHolder[]> parameterList, boolean rewriteValues) throws SQLException
executeBatchRewrite
in interface Protocol
mustExecuteOnMaster
- was intended to be launched on master connectionresults
- resultprepareResult
- prepareResultparameterList
- parametersrewriteValues
- is rewritable flag
SQLException
- exceptionpublic ServerPrepareResult prepareAndExecutes(boolean mustExecuteOnMaster, ServerPrepareResult serverPrepareResult, Results results, String sql, List<ParameterHolder[]> parametersList) throws SQLException
prepareAndExecutes
in interface Protocol
mustExecuteOnMaster
- must normally be executed on master connectionserverPrepareResult
- prepare result. can be null if not prepared.results
- execution resultssql
- sql query if needed to be preparedparametersList
- parameter list
SQLException
- if parameter error or connection error occur.public ServerPrepareResult prepareAndExecute(boolean mustExecuteOnMaster, ServerPrepareResult serverPrepareResult, Results results, String sql, ParameterHolder[] parameters) throws SQLException
prepareAndExecute
in interface Protocol
mustExecuteOnMaster
- must normally be executed on master connectionserverPrepareResult
- prepare result. can be null if not prepared.results
- execution resultssql
- sql query if needed to be preparedparameters
- parameters
SQLException
- if parameter error or connection error occur.public void executePreparedQuery(boolean mustExecuteOnMaster, ServerPrepareResult serverPrepareResult, Results results, ParameterHolder[] parameters) throws SQLException
executePreparedQuery
in interface Protocol
mustExecuteOnMaster
- must execute on masterserverPrepareResult
- prepare resultresults
- execution resultparameters
- parameters
SQLException
- exceptionpublic void rollback() throws SQLException
rollback
in interface Protocol
SQLException
public boolean forceReleasePrepareStatement(int statementId) throws SQLException
forceReleasePrepareStatement
in interface Protocol
statementId
- prepared statement Id to remove.
SQLException
- if connection exception.public void forceReleaseWaitingPrepareStatement() throws SQLException
forceReleaseWaitingPrepareStatement
in interface Protocol
SQLException
- if connection occurpublic boolean ping() throws SQLException
ping
in interface Protocol
SQLException
public boolean isValid() throws SQLException
isValid
in interface Protocol
SQLException
public void setCatalog(String database) throws SQLException
setCatalog
in interface Protocol
SQLException
public void cancelCurrentQuery() throws SQLException, IOException
cancelCurrentQuery
in interface Protocol
SQLException
- never thrown
IOException
- if Host is not respondingpublic boolean getAutocommit()
getAutocommit
in interface Protocol
public boolean inTransaction()
inTransaction
in interface Protocol
public void closeExplicit()
closeExplicit
in interface Protocol
public void releasePrepareStatement(ServerPrepareResult serverPrepareResult) throws SQLException
releasePrepareStatement
in interface Protocol
serverPrepareResult
- allocation result
SQLException
- if deallocation failed.public void setInternalMaxRows(long max)
setInternalMaxRows
in interface Protocol
max
- row number max valuepublic long getMaxRows()
getMaxRows
in interface Protocol
public void setMaxRows(long max) throws SQLException
setMaxRows
in interface Protocol
SQLException
public void setLocalInfileInputStream(InputStream inputStream)
setLocalInfileInputStream
in interface Protocol
public int getTimeout() throws SocketException
getTimeout
in interface Protocol
SocketException
- if there is an error in the underlying protocol, such as a TCP error.public void setTimeout(int timeout) throws SocketException
setTimeout
in interface Protocol
timeout
- the timeout, in milliseconds
SocketException
- if there is an error in the underlying protocol, such as a TCP error.public void setTransactionIsolation(int level) throws SQLException
setTransactionIsolation
in interface Protocol
level
- transaction level.
SQLException
- if transaction level is unknownpublic int getTransactionIsolationLevel()
getTransactionIsolationLevel
in interface Protocol
public void getResult(Results results) throws SQLException
getResult
in interface Protocol
SQLException
public void readPacket(Results results) throws SQLException
results
- result object
SQLException
- if sub-result connection failpublic void readOkPacket(Buffer buffer, Results results) throws SQLException
buffer
- current bufferresults
- result object
SQLException
- if sub-result connection failpublic int getAutoIncrementIncrement()
getAutoIncrementIncrement
in interface Protocol
public SQLException readErrorPacket(Buffer buffer, Results results)
buffer
- current bufferresults
- result object
public void readLocalInfilePacket(Buffer buffer, Results results) throws SQLException
buffer
- current bufferresults
- result object
SQLException
- if sub-result connection failpublic void readResultSet(Buffer buffer, Results results) throws SQLException
buffer
- current bufferresults
- result object
SQLException
- if sub-result connection failpublic void prologProxy(ServerPrepareResult serverPrepareResult, long maxRows, boolean hasProxy, MariaDbConnection connection, MariaDbStatement statement) throws SQLException
prologProxy
in interface Protocol
SQLException
public void prolog(long maxRows, boolean hasProxy, MariaDbConnection connection, MariaDbStatement statement) throws SQLException
prolog
in interface Protocol
maxRows
- query max rowshasProxy
- has proxyconnection
- current connectionstatement
- current statement
SQLException
- if any error occur.public ServerPrepareResult addPrepareInCache(String key, ServerPrepareResult serverPrepareResult)
addPrepareInCache
in interface Protocol
public void resetStateAfterFailover(long maxRows, int transactionIsolationLevel, String database, boolean autocommit) throws SQLException
resetStateAfterFailover
in interface Protocol
maxRows
- current Max rowstransactionIsolationLevel
- current transactionIsolationLeveldatabase
- current databaseautocommit
- current autocommit state
SQLException
- if any error occur.public SQLException handleIoException(IOException initialException)
There is 3 kind of IOException :
handleIoException
in interface Protocol
initialException
- initial Io error
public void setActiveFutureTask(FutureTask activeFutureTask)
setActiveFutureTask
in interface Protocol
public boolean isInterrupted()
isInterrupted
in interface Protocol
public void stopIfInterrupted() throws SQLTimeoutException
stopIfInterrupted
in interface Protocol
SQLTimeoutException
- to indicate timeout exception.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |