public class AbstractQueryProtocol extends AbstractConnectProtocol implements Protocol
activeResult, connected, currentHost, database, dataTypeMappingFlags, explicitClosed, hasWarnings, lock, moreResults, packetFetcher, prepareStatementCache, proxy, readOnly, serverStatus, serverThreadId, socket, urlParser, writer
Constructor and Description |
---|
AbstractQueryProtocol(UrlParser urlParser,
ReentrantLock lock)
Get a protocol instance.
|
Modifier and Type | Method and Description |
---|---|
void |
cancelCurrentQuery()
Cancels the current query - clones the current protocol and executes a query using the new connection.
|
void |
closeExplicit() |
void |
closeIfActiveResult()
Close active result.
|
AbstractQueryResult |
executePreparedQuery(PrepareResult prepareResult,
String sql,
ParameterHolder[] parameters,
MariaDbType[] parameterTypeHeader,
boolean isStreaming) |
AbstractQueryResult |
executePreparedQueryAfterFailover(PrepareResult oldPrepareResult,
String sql,
ParameterHolder[] parameters,
MariaDbType[] parameterTypeHeader,
boolean isStreaming) |
AbstractQueryResult |
executeQueries(List<String> queryParts,
List<ParameterHolder[]> parameterList,
boolean streaming,
boolean isRewritable)
Specific execution for batch rewrite that has specific query for memory.
|
AbstractQueryResult |
executeQuery(List<String> queries,
boolean streaming,
boolean isRewritable,
int rewriteOffset)
Execute list of queries.
|
AbstractQueryResult |
executeQuery(String sql,
boolean streaming)
Execute query.
|
void |
forceReleasePrepareStatement(int statementId)
Force release of prepare statement that are not used.
|
boolean |
getAutocommit() |
int |
getMaxRows() |
AbstractQueryResult |
getMoreResults(boolean streaming) |
AbstractQueryResult |
getResult(boolean streaming,
boolean binaryProtocol) |
int |
getTimeout()
Returns the connection timeout in milliseconds.
|
int |
getTransactionIsolationLevel() |
boolean |
hasMoreResults() |
static String |
hexdump(byte[] buffer,
int offset)
Hexdump.
|
static String |
hexdump(ByteBuffer bb,
int offset)
Hexdump.
|
boolean |
inTransaction() |
boolean |
ping() |
PrepareResult |
prepare(String sql,
boolean forceNew) |
PrepareStatementCache |
prepareStatementCache() |
void |
prolog(boolean isStreaming,
int maxRows,
boolean hasProxy,
MariaDbConnection connection,
Statement statement)
Preparation before command.
|
void |
prologProxy(PrepareResult prepareResult,
boolean isStreaming,
int maxRows,
boolean hasProxy,
MariaDbConnection connection,
Statement statement) |
void |
releasePrepareStatement(PrepareResult prepareResult,
String sql)
Deallocate prepare statement if not used anymore.
|
void |
rollback()
Rollback transaction.
|
void |
setCatalog(String database) |
void |
setInternalMaxRows(int max)
Set max row retuen by a statement.
|
void |
setLocalInfileInputStream(InputStream inputStream) |
void |
setMaxRows(int max) |
void |
setTimeout(int timeout)
Sets the connection timeout.
|
void |
setTransactionIsolation(int level)
Set transaction isolation.
|
checkIfMaster, close, close, connect, connectWithoutProxy, getCalendar, getDatabase, getDataTypeMappingFlags, getHost, getHostAddress, getMajorServerVersion, getMinorServerVersion, getOptions, getPassword, getPinGlobalTxToPhysicalConnection, getPort, getProxy, getReadonly, getServerData, getServerThreadId, getServerVersion, getUrlParser, getUsername, hasWarnings, isClosed, isConnected, isExplicitClosed, isMasterConnection, mustBeMasterConnection, noBackslashEscapes, readEofPacket, setHostAddress, setHostFailedWithoutProxy, setProxy, setReadonly, shouldReconnectWithoutProxy, versionGreaterOrEqual
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkIfMaster, close, connect, connectWithoutProxy, getCalendar, getDatabase, getDataTypeMappingFlags, getHost, getHostAddress, getMajorServerVersion, getMinorServerVersion, getOptions, getPassword, getPinGlobalTxToPhysicalConnection, getPort, getProxy, getReadonly, getServerData, getServerThreadId, getServerVersion, getUrlParser, getUsername, hasWarnings, isClosed, isConnected, isExplicitClosed, isMasterConnection, mustBeMasterConnection, noBackslashEscapes, setHostAddress, setHostFailedWithoutProxy, setProxy, setReadonly, shouldReconnectWithoutProxy, versionGreaterOrEqual
public AbstractQueryProtocol(UrlParser urlParser, ReentrantLock lock)
urlParser
- connection URL infoslock
- the lock for thread synchronisationpublic static String hexdump(byte[] buffer, int offset)
buffer
- byte arrayoffset
- offsetpublic static String hexdump(ByteBuffer bb, int offset)
bb
- bytebufferoffset
- offsetpublic PrepareResult prepare(String sql, boolean forceNew) throws QueryException
prepare
in interface Protocol
QueryException
public boolean getAutocommit()
getAutocommit
in interface Protocol
public boolean inTransaction()
inTransaction
in interface Protocol
public boolean hasMoreResults()
hasMoreResults
in interface Protocol
public void closeExplicit()
closeExplicit
in interface Protocol
public void setCatalog(String database) throws QueryException
setCatalog
in interface Protocol
QueryException
public boolean ping() throws QueryException
ping
in interface Protocol
QueryException
public AbstractQueryResult executePreparedQueryAfterFailover(PrepareResult oldPrepareResult, String sql, ParameterHolder[] parameters, MariaDbType[] parameterTypeHeader, boolean isStreaming) throws QueryException
executePreparedQueryAfterFailover
in interface Protocol
QueryException
public AbstractQueryResult executePreparedQuery(PrepareResult prepareResult, String sql, ParameterHolder[] parameters, MariaDbType[] parameterTypeHeader, boolean isStreaming) throws QueryException
executePreparedQuery
in interface Protocol
QueryException
public void releasePrepareStatement(PrepareResult prepareResult, String sql) throws QueryException
releasePrepareStatement
in interface Protocol
prepareResult
- allocation resultsql
- sql queryQueryException
- if deallocation failed.public void forceReleasePrepareStatement(int statementId) throws QueryException
forceReleasePrepareStatement
in interface Protocol
statementId
- prepared statement Id to remove.QueryException
- if connection exception.public void cancelCurrentQuery() throws QueryException, IOException
cancelCurrentQuery
in interface Protocol
QueryException
- never thrownIOException
- if Host is not respondingpublic AbstractQueryResult getMoreResults(boolean streaming) throws QueryException
getMoreResults
in interface Protocol
getMoreResults
in class AbstractConnectProtocol
QueryException
public void setInternalMaxRows(int max)
setInternalMaxRows
in interface Protocol
max
- row number max valuepublic int getMaxRows()
getMaxRows
in interface Protocol
public void setMaxRows(int max) throws QueryException
setMaxRows
in interface Protocol
QueryException
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 millisecondsSocketException
- if there is an error in the underlying protocol, such as a TCP error.public void setTransactionIsolation(int level) throws QueryException
setTransactionIsolation
in interface Protocol
level
- transaction level.QueryException
- if transaction level is unknownpublic int getTransactionIsolationLevel()
getTransactionIsolationLevel
in interface Protocol
public void closeIfActiveResult()
closeIfActiveResult
in interface Protocol
public PrepareStatementCache prepareStatementCache()
prepareStatementCache
in interface Protocol
public AbstractQueryResult executeQuery(String sql, boolean streaming) throws QueryException
executeQuery
in interface Protocol
sql
- the query to executeInternalstreaming
- is streaming flagQueryException
- exceptionpublic AbstractQueryResult executeQuery(List<String> queries, boolean streaming, boolean isRewritable, int rewriteOffset) throws QueryException
executeQuery
in interface Protocol
queries
- list of queryesstreaming
- is streaming flagisRewritable
- is rewritable flagrewriteOffset
- rewrite offsetQueryException
- exceptionpublic AbstractQueryResult executeQueries(List<String> queryParts, List<ParameterHolder[]> parameterList, boolean streaming, boolean isRewritable) throws QueryException
executeQueries
in interface Protocol
queryParts
- query partparameterList
- parametersstreaming
- is streaming flagisRewritable
- is rewritable flagQueryException
- exceptionpublic AbstractQueryResult getResult(boolean streaming, boolean binaryProtocol) throws QueryException
getResult
in interface Protocol
QueryException
public void prologProxy(PrepareResult prepareResult, boolean isStreaming, int maxRows, boolean hasProxy, MariaDbConnection connection, Statement statement) throws SQLException
prologProxy
in interface Protocol
SQLException
public void prolog(boolean isStreaming, int maxRows, boolean hasProxy, MariaDbConnection connection, Statement statement) throws SQLException
prolog
in interface Protocol
isStreaming
- is streamingmaxRows
- query max rowshasProxy
- has proxyconnection
- current connectionstatement
- current statementSQLException
- if any error occur.Copyright © 2016. All rights reserved.