|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mysql.jdbc.MysqlIO
This class is used by Connection for communicating with the MySQL server.
Connection
Field Summary | |
protected static int |
CLIENT_CONNECT_WITH_DB
|
protected static int |
CLIENT_RESERVED
|
protected static int |
CLIENT_SECURE_CONNECTION
|
protected static int |
CLIENT_SSL
|
protected long |
clientParam
|
protected static int |
COMP_HEADER_LENGTH
|
protected Connection |
connection
|
protected static int |
HEADER_LENGTH
|
protected java.lang.String |
host
|
protected long |
lastPacketSentTimeMs
|
protected static int |
MAX_QUERY_SIZE_TO_EXPLAIN
|
protected static int |
MAX_QUERY_SIZE_TO_LOG
|
protected int |
maxThreeBytes
|
protected static int |
MIN_COMPRESS_LEN
|
protected java.net.Socket |
mysqlConnection
The connection to the server |
protected java.io.InputStream |
mysqlInput
|
protected java.io.BufferedOutputStream |
mysqlOutput
Data to the server |
protected static int |
NULL_LENGTH
|
protected int |
port
|
(package private) byte |
protocolVersion
|
protected java.lang.String |
seed
|
protected int |
serverCapabilities
|
protected int |
serverCharsetIndex
|
protected static java.lang.String |
ZERO_DATE_VALUE_MARKER
We need to have a 'marker' for all-zero datetimes so that ResultSet can decide what to do based on connection setting |
protected static java.lang.String |
ZERO_DATETIME_VALUE_MARKER
|
Constructor Summary | |
MysqlIO(java.lang.String host,
int port,
java.util.Properties props,
java.lang.String socketFactoryClassName,
Connection conn,
int socketTimeout)
Constructor: Connect to the MySQL server and setup a stream connection. |
Method Summary | |
protected void |
changeUser(java.lang.String userName,
java.lang.String password,
java.lang.String database)
Re-authenticates as the given user and password |
protected Buffer |
checkErrorPacket()
Checks for errors in the reply packet, and if none, returns the reply packet, ready for reading |
protected void |
checkForCharsetMismatch()
Determines if the database charset is the same as the platform charset |
protected void |
clearInputStream()
|
(package private) void |
closeStreamer(RowData streamer)
|
(package private) void |
disableMultiQueries()
|
(package private) void |
doHandshake(java.lang.String user,
java.lang.String password,
java.lang.String database)
Initialize communications with the MySQL server. |
protected void |
dumpPacketRingBuffer()
|
(package private) void |
enableMultiQueries()
|
protected void |
explainSlowQuery(byte[] querySQL,
java.lang.String truncatedQuery)
Runs an 'EXPLAIN' on the given query and dumps the results to the log |
protected java.util.List |
fetchRowsViaCursor(java.util.List fetchedRows,
long statementId,
Field[] columnTypes,
int fetchSize)
|
protected void |
forceClose()
Forcibly closes the underlying socket to MySQL. |
(package private) java.lang.String |
getHost()
Returns the host this IO is connected to |
protected long |
getLastPacketSentTimeMs()
DOCUMENT ME! |
(package private) static int |
getMaxBuf()
|
protected ResultSet |
getResultSet(Statement callingStatement,
long columnCount,
int maxRows,
int resultSetType,
int resultSetConcurrency,
boolean streamResults,
java.lang.String catalog,
boolean isBinaryEncoded,
boolean unpackFieldInfo,
Field[] metadataFromCache)
Build a result set. |
(package private) int |
getServerMajorVersion()
Get the major version of the MySQL server we are talking to. |
(package private) int |
getServerMinorVersion()
Get the minor version of the MySQL server we are talking to. |
protected int |
getServerStatus()
|
(package private) int |
getServerSubMinorVersion()
Get the sub-minor version of the MySQL server we are talking to. |
(package private) java.lang.String |
getServerVersion()
Get the version string of the server we are talking to |
(package private) Buffer |
getSharedSendPacket()
Returns the packet used for sending data (used by PreparedStatement) Guarded by external synchronization on a mutex. |
protected long |
getThreadId()
|
(package private) boolean |
hadWarnings()
|
boolean |
hasLongColumnInfo()
Does the server send back extra column info? |
protected boolean |
isDataAvailable()
|
protected boolean |
isSetNeededForAutoCommitMode(boolean autoCommitFlag)
|
(package private) boolean |
isVersion(int major,
int minor,
int subminor)
Is the version of the MySQL server we are connected to the given version? |
(package private) java.lang.Object[] |
nextRow(Field[] fields,
int columnCount,
boolean isBinaryEncoded,
int resultSetConcurrency)
Retrieve one row from the MySQL server. |
(package private) void |
quit()
Log-off of the MySQL server and close the socket. |
(package private) ResultSet |
readAllResults(Statement callingStatement,
int maxRows,
int resultSetType,
int resultSetConcurrency,
boolean streamResults,
java.lang.String catalog,
Buffer resultPacket,
boolean isBinaryEncoded,
long preSentColumnCount,
boolean unpackFieldInfo,
Field[] metadataFromCache)
|
protected Buffer |
readPacket()
Read one packet from the MySQL server |
(package private) void |
resetMaxBuf()
Sets the buffer size to max-buf |
protected void |
resetReadPacketSequence()
|
(package private) void |
scanForAndThrowDataTruncation()
|
(package private) void |
secureAuth411(Buffer packet,
int packLength,
java.lang.String user,
java.lang.String password,
java.lang.String database,
boolean writeClientParams)
Secure authentication for 4.1.1 and newer servers. |
(package private) Buffer |
sendCommand(int command,
java.lang.String extraData,
Buffer queryPacket,
boolean skipCheck,
java.lang.String extraDataCharEncoding)
Send a command to the MySQL server If data is to be sent with command, it should be put in extraData. |
protected void |
skipPacket()
Reads and discards a single MySQL packet from the input stream. |
(package private) ResultSet |
sqlQueryDirect(Statement callingStatement,
java.lang.String query,
java.lang.String characterEncoding,
Buffer queryPacket,
int maxRows,
Connection conn,
int resultSetType,
int resultSetConcurrency,
boolean streamResults,
java.lang.String catalog,
boolean unpackFieldInfo)
Send a query stored in a packet directly to the server. |
protected Field |
unpackField(Buffer packet,
boolean extractDefaultValues)
Unpacks the Field information from the given packet. |
(package private) boolean |
versionMeetsMinimum(int major,
int minor,
int subminor)
Does the version of the MySQL server we are connected to meet the given minimums? |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final int NULL_LENGTH
protected static final int COMP_HEADER_LENGTH
protected static final int MIN_COMPRESS_LEN
protected static final int HEADER_LENGTH
protected static final int CLIENT_CONNECT_WITH_DB
protected static final int CLIENT_SSL
protected static final int CLIENT_RESERVED
protected static final int CLIENT_SECURE_CONNECTION
protected static final int MAX_QUERY_SIZE_TO_LOG
protected static final int MAX_QUERY_SIZE_TO_EXPLAIN
protected static final java.lang.String ZERO_DATE_VALUE_MARKER
protected static final java.lang.String ZERO_DATETIME_VALUE_MARKER
protected int serverCharsetIndex
protected java.io.BufferedOutputStream mysqlOutput
protected Connection connection
protected java.io.InputStream mysqlInput
protected java.net.Socket mysqlConnection
protected java.lang.String host
protected java.lang.String seed
byte protocolVersion
protected int maxThreeBytes
protected int port
protected int serverCapabilities
protected long clientParam
protected long lastPacketSentTimeMs
Constructor Detail |
public MysqlIO(java.lang.String host, int port, java.util.Properties props, java.lang.String socketFactoryClassName, Connection conn, int socketTimeout) throws java.io.IOException, java.sql.SQLException
host
- the hostname to connect toport
- the port number that the server is listening onprops
- the Properties from DriverManager.getConnection()socketFactoryClassName
- the socket factory to useconn
- the Connection that is creating ussocketTimeout
- the timeout to set for the socket (0 means no
timeout)
java.io.IOException
- if an IOException occurs during connect.
java.sql.SQLException
- if a database access error occurs.Method Detail |
public boolean hasLongColumnInfo()
protected boolean isDataAvailable() throws java.sql.SQLException
java.sql.SQLException
protected long getLastPacketSentTimeMs()
protected ResultSet getResultSet(Statement callingStatement, long columnCount, int maxRows, int resultSetType, int resultSetConcurrency, boolean streamResults, java.lang.String catalog, boolean isBinaryEncoded, boolean unpackFieldInfo, Field[] metadataFromCache) throws java.sql.SQLException
callingStatement
- DOCUMENT ME!columnCount
- the number of columns in the result setmaxRows
- the maximum number of rows to read (-1 means all rows)resultSetType
- (TYPE_FORWARD_ONLY, TYPE_SCROLL_????)resultSetConcurrency
- the type of result set (CONCUR_UPDATABLE or
READ_ONLY)streamResults
- should the result set be read all at once, or
streamed?catalog
- the database name in use when the result set was createdisBinaryEncoded
- is this result set in native encoding?unpackFieldInfo
- should we read MYSQL_FIELD info (if available)?
java.sql.SQLException
- if a database access error occursprotected final void forceClose()
protected final void skipPacket() throws java.sql.SQLException
java.sql.SQLException
- if the network fails while skipping the
packet.protected final Buffer readPacket() throws java.sql.SQLException
java.sql.SQLException
- DOCUMENT ME!
CommunicationsException
- DOCUMENT ME!protected final Field unpackField(Buffer packet, boolean extractDefaultValues) throws java.sql.SQLException
packet
- the packet containing the field informationextractDefaultValues
- should default values be extracted?
java.sql.SQLException
- DOCUMENT ME!protected boolean isSetNeededForAutoCommitMode(boolean autoCommitFlag)
protected void changeUser(java.lang.String userName, java.lang.String password, java.lang.String database) throws java.sql.SQLException
userName
- DOCUMENT ME!password
- DOCUMENT ME!database
- DOCUMENT ME!
java.sql.SQLException
- DOCUMENT ME!protected Buffer checkErrorPacket() throws java.sql.SQLException
java.sql.SQLException
- is the packet is an error packetprotected void checkForCharsetMismatch()
protected void clearInputStream() throws java.sql.SQLException
java.sql.SQLException
protected void resetReadPacketSequence()
protected void dumpPacketRingBuffer() throws java.sql.SQLException
java.sql.SQLException
protected void explainSlowQuery(byte[] querySQL, java.lang.String truncatedQuery) throws java.sql.SQLException
querySQL
- DOCUMENT ME!truncatedQuery
- DOCUMENT ME!
java.sql.SQLException
- DOCUMENT ME!static int getMaxBuf()
final int getServerMajorVersion()
final int getServerMinorVersion()
final int getServerSubMinorVersion()
java.lang.String getServerVersion()
void doHandshake(java.lang.String user, java.lang.String password, java.lang.String database) throws java.sql.SQLException
user
- DOCUMENT ME!password
- DOCUMENT ME!database
- DOCUMENT ME!
java.sql.SQLException
- DOCUMENT ME!
CommunicationsException
- DOCUMENT ME!final java.lang.Object[] nextRow(Field[] fields, int columnCount, boolean isBinaryEncoded, int resultSetConcurrency) throws java.sql.SQLException
fields
- DOCUMENT ME!columnCount
- DOCUMENT ME!isBinaryEncoded
- DOCUMENT ME!resultSetConcurrency
- DOCUMENT ME!
java.sql.SQLException
- DOCUMENT ME!final void quit() throws java.sql.SQLException
java.sql.SQLException
- DOCUMENT ME!Buffer getSharedSendPacket()
void closeStreamer(RowData streamer) throws java.sql.SQLException
java.sql.SQLException
ResultSet readAllResults(Statement callingStatement, int maxRows, int resultSetType, int resultSetConcurrency, boolean streamResults, java.lang.String catalog, Buffer resultPacket, boolean isBinaryEncoded, long preSentColumnCount, boolean unpackFieldInfo, Field[] metadataFromCache) throws java.sql.SQLException
java.sql.SQLException
void resetMaxBuf()
final Buffer sendCommand(int command, java.lang.String extraData, Buffer queryPacket, boolean skipCheck, java.lang.String extraDataCharEncoding) throws java.sql.SQLException
command
- the MySQL protocol 'command' from MysqlDefsextraData
- any 'string' data for the commandqueryPacket
- a packet pre-loaded with data for the protocol (i.e.
from a client-side prepared statement).skipCheck
- do not call checkErrorPacket() if trueextraDataCharEncoding
- the character encoding of the extraData
parameter.
java.sql.SQLException
- if an I/O error or SQL error occursfinal ResultSet sqlQueryDirect(Statement callingStatement, java.lang.String query, java.lang.String characterEncoding, Buffer queryPacket, int maxRows, Connection conn, int resultSetType, int resultSetConcurrency, boolean streamResults, java.lang.String catalog, boolean unpackFieldInfo) throws java.lang.Exception
callingStatement
- DOCUMENT ME!resultSetConcurrency
- DOCUMENT ME!characterEncoding
- DOCUMENT ME!queryPacket
- DOCUMENT ME!maxRows
- DOCUMENT ME!conn
- DOCUMENT ME!resultSetType
- DOCUMENT ME!streamResults
- DOCUMENT ME!catalog
- DOCUMENT ME!unpackFieldInfo
- should we read MYSQL_FIELD info (if available)?
java.lang.Exception
- DOCUMENT ME!java.lang.String getHost()
boolean isVersion(int major, int minor, int subminor)
major
- the major versionminor
- the minor versionsubminor
- the subminor version
boolean versionMeetsMinimum(int major, int minor, int subminor)
major
- DOCUMENT ME!minor
- DOCUMENT ME!subminor
- DOCUMENT ME!
void enableMultiQueries() throws java.sql.SQLException
java.sql.SQLException
void disableMultiQueries() throws java.sql.SQLException
java.sql.SQLException
boolean hadWarnings()
void scanForAndThrowDataTruncation() throws java.sql.SQLException
java.sql.SQLException
void secureAuth411(Buffer packet, int packLength, java.lang.String user, java.lang.String password, java.lang.String database, boolean writeClientParams) throws java.sql.SQLException
packet
- DOCUMENT ME!packLength
- user
- password
- database
- DOCUMENT ME!writeClientParams
-
java.sql.SQLException
protected int getServerStatus()
protected java.util.List fetchRowsViaCursor(java.util.List fetchedRows, long statementId, Field[] columnTypes, int fetchSize) throws java.sql.SQLException
java.sql.SQLException
protected long getThreadId()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |