| Constructor and Description |
|---|
MySQLProtocol(String host,
int port,
String database,
String username,
String password,
Properties info)
Get a protocol instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
addToBatch(Query dQuery)
adds a query to the batch
|
void |
cancelCurrentQuery()
cancels the current query - clones the current protocol and executes a query using the new connection
thread safe
|
void |
clearBatch()
clears the current batch
|
void |
close()
Closes socket and stream readers/writers
|
void |
commit()
commits the current transaction
|
boolean |
createDB()
should a database be created if it does not exist ?
|
List<QueryResult> |
executeBatch()
executes the batch of queries
|
QueryResult |
executeQuery(Query dQuery)
executes a query
|
QueryResult |
executeQuery(Query dQuery,
InputStream inputStream) |
String |
getCatalog()
Catalogs are not supported in drizzle so this will always return null
with a Drizzle connection
MySQL treats catalogs as databases. |
String |
getDatabase()
returns the current used database
|
SupportedDatabases |
getDatabaseType() |
String |
getHost()
returns the host
|
QueryResult |
getMoreResults() |
String |
getPassword()
the current password
|
int |
getPort()
returns the port we are connected to
|
boolean |
getReadonly()
check if it is possble to execute writing operations on this connection
|
String |
getServerVariable(String variable) |
String |
getServerVersion()
returns the server version string
|
String |
getUsername()
returns the current connected username
|
static String |
hexdump(byte[] buffer,
int offset) |
static String |
hexdump(ByteBuffer bb,
int offset) |
boolean |
isClosed()
returns true if the connection has been closed
|
boolean |
noPrepStmtCache() |
boolean |
ping()
checks whether the connectiion is still valid
|
void |
releaseSavepoint(String savepoint)
releases the savepoint
|
void |
rollback()
rolls back the current transaction
|
void |
rollback(String savepoint)
rolls back to the given save point
|
void |
selectDB(String database)
selects what database to use
|
void |
setCatalog(String catalog)
Catalogs are not supported in drizzle so this is a no-op with a Drizzle
connection
MySQL treats catalogs as databases. |
void |
setReadonly(boolean readOnly)
sets whether this connection should be read only
TODO: actually enforce this
|
void |
setSavepoint(String savepoint)
sets a save point
|
List<RawPacket> |
startBinlogDump(int startPos,
String filename) |
boolean |
supportsPBMS() |
void |
timeOut() |
public MySQLProtocol(String host, int port, String database, String username, String password, Properties info) throws QueryException
host - the host to connect toport - the port to connect todatabase - the initial databaseusername - the usernamepassword - the passwordinfo - QueryException - if there is a problem reading / sending the packetspublic void close()
throws QueryException
close in interface ProtocolQueryException - if the socket or readers/writes cannot be closedpublic boolean isClosed()
Protocolpublic void selectDB(String database) throws QueryException
ProtocolselectDB in interface Protocoldatabase - the databaseQueryException - if there is a problem selecting the databasepublic String getServerVersion()
ProtocolgetServerVersion in interface Protocolpublic void setReadonly(boolean readOnly)
ProtocolsetReadonly in interface ProtocolreadOnly - if the connection should be read onlypublic boolean getReadonly()
ProtocolgetReadonly in interface Protocolpublic void commit()
throws QueryException
Protocolcommit in interface ProtocolQueryException - if there is a problem committing the txnpublic void rollback()
throws QueryException
Protocolrollback in interface ProtocolQueryException - if there is a problem rolling backpublic void rollback(String savepoint) throws QueryException
Protocolrollback in interface Protocolsavepoint - the save point to roll back toQueryException - if there is a problem rolling backpublic void setSavepoint(String savepoint) throws QueryException
ProtocolsetSavepoint in interface Protocolsavepoint - the save point nameQueryException - if there is a problem setting the save pointpublic void releaseSavepoint(String savepoint) throws QueryException
ProtocolreleaseSavepoint in interface Protocolsavepoint - the name of the savepoint to releaseQueryException - if there is a problem releasing the save pointpublic int getPort()
Protocolpublic String getDatabase()
ProtocolgetDatabase in interface Protocolpublic String getUsername()
ProtocolgetUsername in interface Protocolpublic String getPassword()
ProtocolgetPassword in interface Protocolpublic boolean ping()
throws QueryException
Protocolping in interface ProtocolQueryException - if there is a problem communicatingpublic QueryResult executeQuery(Query dQuery) throws QueryException
ProtocolexecuteQuery in interface ProtocoldQuery - the query to executeQueryException - if there is a problem with the querypublic void addToBatch(Query dQuery)
ProtocoladdToBatch in interface ProtocoldQuery - the query to addpublic List<QueryResult> executeBatch() throws QueryException
ProtocolexecuteBatch in interface ProtocolQueryException - if there is a problempublic void clearBatch()
ProtocolclearBatch in interface Protocolpublic List<RawPacket> startBinlogDump(int startPos, String filename) throws BinlogDumpException
startBinlogDump in interface ProtocolBinlogDumpExceptionpublic SupportedDatabases getDatabaseType()
getDatabaseType in interface Protocolpublic boolean supportsPBMS()
supportsPBMS in interface Protocolpublic String getServerVariable(String variable) throws QueryException
getServerVariable in interface ProtocolQueryExceptionpublic QueryResult executeQuery(Query dQuery, InputStream inputStream) throws QueryException
executeQuery in interface ProtocolQueryExceptionpublic void cancelCurrentQuery()
throws QueryException
cancelCurrentQuery in interface ProtocolQueryExceptionpublic void timeOut()
throws QueryException
timeOut in interface ProtocolQueryExceptionpublic boolean createDB()
Protocolpublic boolean noPrepStmtCache()
noPrepStmtCache in interface Protocolpublic QueryResult getMoreResults() throws QueryException
getMoreResults in interface ProtocolQueryExceptionpublic static String hexdump(byte[] buffer, int offset)
public static String hexdump(ByteBuffer bb, int offset)
public void setCatalog(String catalog) throws QueryException
selectDB(String) is that the catalog is switched
inside the connection using SQL 'USE' commandsetCatalog in interface Protocolcatalog - the name of a catalog (subspace in this Connection object's database) in which to
workQueryException - if a database access error occurs or this method is called on a closed connectionProtocol.getCatalog()public String getCatalog() throws QueryException
getCatalog in interface Protocolnull if there is noneQueryException - if a database access error occurs or this method is called on a closed connectionProtocol.setCatalog(java.lang.String)Copyright © 2016. All rights reserved.