|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.continuent.tungsten.common.mysql.MySQLIOs
public class MySQLIOs
Utility class to retrieve the input and output streams of a JDBC Connection
to a MySQL server. These IOs serve the mean of fast and direct interactions
with the server (also known as pass-through mode).
Current implementation allows IOs retrieval for both MySQL and Drizzle
drivers even when behind the SQL-Router or a c3p0 connection pool
| Nested Class Summary | |
|---|---|
static class |
MySQLIOs.ExecuteQueryStatus
|
| Field Summary | |
|---|---|
static java.lang.String |
MYSQL_ERRNO
|
static java.lang.String |
MYSQL_SQL_STATE
|
static java.lang.String |
RESULT_KEY
|
static java.lang.String |
SOCKET_PHASE_CONNECT
|
static java.lang.String |
SOCKET_PHASE_READ
|
static java.lang.String |
SOCKET_PHASE_WRITE
|
static java.lang.String |
STATUS_EXCEPTION
|
static java.lang.String |
STATUS_KEY
|
static java.lang.String |
STATUS_MESSAGE_KEY
|
static java.lang.String |
TIME_TO_CONNECT_MS
|
static java.lang.String |
TIME_TO_EXEC_QUERY_MS
|
static java.lang.String |
TIME_TO_INIT_MS
|
| Method Summary | |
|---|---|
static boolean |
connectionIsCompatible(java.sql.Connection conn)
Tells whether the given connection is one that we can exploit for the purposes of getting access to MySQL IOs. |
static byte[] |
encryptMySQLPassword(java.lang.String password,
byte[] seed)
Do a MySQL specific encryption of the given password Algorithm is: stage1_hash = SHA1(password) token = SHA1(scramble + SHA1(stage1_hash)) XOR stage1_hash |
static TungstenProperties |
executeQueryWithTimeouts(java.lang.String hostname,
int port,
java.lang.String user,
java.lang.String password,
java.lang.String db,
java.lang.String query,
int timeoutMsecs)
Tries to establish a connection to a MySQL server with given credentials and timeout. |
static java.lang.Object |
extractInnerConnection(java.sql.Connection connection)
A pooled or SQL-Router JDBC connection wraps the original MySQL connection object. |
static java.lang.Object |
extractInnerConnectionFromBoneCP(java.lang.Object pooledConnection)
Given a BoneCP pooled connection, extracts the enclosed "real" connection |
static java.lang.Object |
extractInnerConnectionFromC3P0(java.lang.Object pooledConnection)
Given a C3P0 pooled connection, extracts the enclosed "real" connection |
static java.lang.Object |
extractInnerConnectionFromPooledConnection(java.lang.Object pooledConnection,
java.lang.String memberVariableName)
Given a connection pool connection, extracts the enclosed "real" connection |
static java.lang.Object |
extractInnerConnectionFromSQLR(java.lang.Object sqlrConnection)
Given a SQL-Router connection, retrieve the encapsulated connection |
static void |
forceClose(java.sql.Connection conn)
|
java.io.InputStream |
getInput()
|
static MySQLIOs |
getMySQLIOs(java.sql.Connection connection)
Extracts MySQL server input and output streams from the given connection. |
java.io.BufferedOutputStream |
getOutput()
|
static long |
getServerThreadID(java.sql.Connection connection)
Every connection to a MySQL server has a server side ID, called connection ID or server thread ID. |
static ResourceState |
getStateFromQueryStatus(MySQLIOs.ExecuteQueryStatus status)
Returns the ResourceState that maps to the status of the query execution. |
static boolean |
isAlive(java.lang.String hostname,
int port,
java.lang.String user,
java.lang.String password,
java.lang.String db,
java.lang.String query,
int timeoutMsecs)
Checks a MySQL server connectivity by running the given query against it. |
static void |
loadStateMappingConfiguration()
|
static java.lang.String |
showStateMapping()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String STATUS_KEY
public static final java.lang.String STATUS_EXCEPTION
public static final java.lang.String MYSQL_ERRNO
public static final java.lang.String MYSQL_SQL_STATE
public static final java.lang.String STATUS_MESSAGE_KEY
public static final java.lang.String RESULT_KEY
public static final java.lang.String TIME_TO_CONNECT_MS
public static final java.lang.String TIME_TO_INIT_MS
public static final java.lang.String TIME_TO_EXEC_QUERY_MS
public static final java.lang.String SOCKET_PHASE_CONNECT
public static final java.lang.String SOCKET_PHASE_READ
public static final java.lang.String SOCKET_PHASE_WRITE
| Method Detail |
|---|
public static MySQLIOs getMySQLIOs(java.sql.Connection connection)
throws java.io.IOException
connection - a jdbc connection object that must be connected to a
MySQL server
java.io.IOException - if the streams could not be extracted
public static java.lang.Object extractInnerConnection(java.sql.Connection connection)
throws java.io.IOException
connection - a regular, pooled or SQL-Router connection
java.io.IOException - upon problems getting the inner connection
public static java.lang.Object extractInnerConnectionFromC3P0(java.lang.Object pooledConnection)
throws java.io.IOException
pooledConnection - a c3p0-pooled connection
java.io.IOException - if an error occurs retrieving inner connection
public static java.lang.Object extractInnerConnectionFromBoneCP(java.lang.Object pooledConnection)
throws java.io.IOException
pooledConnection - a boneCP-pooled connection
java.io.IOException - if an error occurs retrieving inner connection
public static java.lang.Object extractInnerConnectionFromPooledConnection(java.lang.Object pooledConnection,
java.lang.String memberVariableName)
throws java.io.IOException
pooledConnection - a c3p0 or boneCP -pooled connectionmemberVariableName - name of the inner connection variable
java.io.IOException - if an error occurs retrieving inner connection
public static java.lang.Object extractInnerConnectionFromSQLR(java.lang.Object sqlrConnection)
throws java.io.IOException
sqlrConnection - Tungsten SQL-router connection
java.io.IOException - if an error occurs retrieving inner connectionpublic static long getServerThreadID(java.sql.Connection connection)
connection - the (connected) connection to get ID from
public static boolean connectionIsCompatible(java.sql.Connection conn)
conn - connection to test
public java.io.InputStream getInput()
public java.io.BufferedOutputStream getOutput()
public static boolean isAlive(java.lang.String hostname,
int port,
java.lang.String user,
java.lang.String password,
java.lang.String db,
java.lang.String query,
int timeoutMsecs)
executeQueryWithTimeouts(String, int, String, String, String, String, int)
hostname - port - user - password - db - null or empty when not wanting to connect to any DBquery - the query to be executed against the server - only selects
are supportedtimeoutMsecs - must be positive. Zero timeout is considered as no
timeout
public static TungstenProperties executeQueryWithTimeouts(java.lang.String hostname,
int port,
java.lang.String user,
java.lang.String password,
java.lang.String db,
java.lang.String query,
int timeoutMsecs)
hostname - port - user - password - db - null or empty when not wanting to connect to any DBquery - the query to be executed against the server - only selects
are supportedtimeoutMsecs - must be positive. Zero timeout is considered as no
timeout
public static byte[] encryptMySQLPassword(java.lang.String password,
byte[] seed)
password - the password to scrambleseed - the server seed to encode the password with
public static void forceClose(java.sql.Connection conn)
public static ResourceState getStateFromQueryStatus(MySQLIOs.ExecuteQueryStatus status)
status -
public static void loadStateMappingConfiguration()
throws ConfigurationException
ConfigurationExceptionpublic static java.lang.String showStateMapping()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||