| java.lang.Object com.mysql.jdbc.MysqlIO
MysqlIO | class MysqlIO (Code) | | This class is used by Connection for communicating with the MySQL server.
author: Mark Matthews version: $Id: MysqlIO.java 6496 2007-08-13 20:22:33Z mmatthews $ See Also: java.sql.Connection |
Constructor Summary | |
public | MysqlIO(String host, int port, Properties props, String socketFactoryClassName, ConnectionImpl conn, int socketTimeout, int useBufferRowSizeThreshold) Constructor: Connect to the MySQL server and setup a stream connection. |
Method Summary | |
protected void | changeUser(String userName, String password, String database) | protected Buffer | checkErrorPacket() | protected void | checkForCharsetMismatch() | protected void | clearInputStream() | void | closeStreamer(RowData streamer) | void | disableMultiQueries() | void | doHandshake(String user, String password, String database) Initialize communications with the MySQL server. | protected void | dumpPacketRingBuffer() | void | enableMultiQueries() | protected void | explainSlowQuery(byte[] querySQL, String truncatedQuery) | protected List | fetchRowsViaCursor(List fetchedRows, long statementId, Field[] columnTypes, int fetchSize, boolean useBufferRowExplicit) | final protected void | forceClose() Forcibly closes the underlying socket to MySQL. | protected long | getCurrentTimeNanosOrMillis() | String | getHost() | protected long | getLastPacketSentTimeMs() | static int | getMaxBuf() | protected String | getQueryTimingUnits() | protected ResultSetImpl | getResultSet(StatementImpl callingStatement, long columnCount, int maxRows, int resultSetType, int resultSetConcurrency, boolean streamResults, String catalog, boolean isBinaryEncoded, Field[] metadataFromCache) Build a result set. | final int | getServerMajorVersion() Get the major version of the MySQL server we are talking to. | final int | getServerMinorVersion() Get the minor version of the MySQL server we are talking to. | protected int | getServerStatus() | final int | getServerSubMinorVersion() Get the sub-minor version of the MySQL server we are talking to. | String | getServerVersion() | Buffer | getSharedSendPacket() Returns the packet used for sending data (used by PreparedStatement)
Guarded by external synchronization on a mutex. | protected long | getSlowQueryThreshold() | protected long | getThreadId() | boolean | hadWarnings() | public boolean | hasLongColumnInfo() | protected boolean | inTransactionOnServer() | protected void | initializeStatementInterceptors(String interceptorClasses, Properties props) | protected boolean | isDataAvailable() | protected boolean | isSetNeededForAutoCommitMode(boolean autoCommitFlag) | boolean | isVersion(int major, int minor, int subminor) | final ResultSetRow | nextRow(Field[] fields, int columnCount, boolean isBinaryEncoded, int resultSetConcurrency, boolean useBufferRowIfPossible, boolean useBufferRowExplicit, boolean canReuseRowPacketForBufferRow, Buffer existingRowPacket) Retrieve one row from the MySQL server. | final ResultSetRow | nextRowFast(Field[] fields, int columnCount, boolean isBinaryEncoded, int resultSetConcurrency, boolean useBufferRowIfPossible, boolean useBufferRowExplicit, boolean canReuseRowPacket) | final void | quit() Log-off of the MySQL server and close the socket. | ResultSetImpl | readAllResults(StatementImpl callingStatement, int maxRows, int resultSetType, int resultSetConcurrency, boolean streamResults, String catalog, Buffer resultPacket, boolean isBinaryEncoded, long preSentColumnCount, Field[] metadataFromCache) | final protected Buffer | readPacket() | void | resetMaxBuf() | protected void | resetReadPacketSequence() | void | scanForAndThrowDataTruncation() | void | secureAuth411(Buffer packet, int packLength, String user, String password, String database, boolean writeClientParams) Secure authentication for 4.1.1 and newer servers. | final Buffer | sendCommand(int command, String extraData, Buffer queryPacket, boolean skipCheck, String extraDataCharEncoding) Send a command to the MySQL server If data is to be sent with command,
it should be put in extraData.
Raw packets can be sent by setting queryPacket to something other
than null.
Parameters: command - the MySQL protocol 'command' from MysqlDefs Parameters: extraData - any 'string' data for the command Parameters: queryPacket - a packet pre-loaded with data for the protocol (i.e.from a client-side prepared statement). Parameters: skipCheck - do not call checkErrorPacket() if true Parameters: extraDataCharEncoding - the character encoding of the extraDataparameter. | final protected void | skipPacket() Reads and discards a single MySQL packet from the input stream. | final ResultSetInternalMethods | sqlQueryDirect(StatementImpl callingStatement, String query, String characterEncoding, Buffer queryPacket, int maxRows, int resultSetType, int resultSetConcurrency, boolean streamResults, String catalog, Field[] cachedMetadata) Send a query stored in a packet directly to the server. | final protected Field | unpackField(Buffer packet, boolean extractDefaultValues) Unpacks the Field information from the given packet. | public static boolean | useBufferRowExplicit(Field[] fields) | protected boolean | useNanosForElapsedTime() | boolean | versionMeetsMinimum(int major, int minor, int subminor) |
AUTH_411_OVERHEAD | final protected static int AUTH_411_OVERHEAD(Code) | | |
CLIENT_CONNECT_WITH_DB | final protected static int CLIENT_CONNECT_WITH_DB(Code) | | |
CLIENT_RESERVED | final protected static int CLIENT_RESERVED(Code) | | |
CLIENT_SECURE_CONNECTION | final protected static int CLIENT_SECURE_CONNECTION(Code) | | |
CLIENT_SSL | final protected static int CLIENT_SSL(Code) | | |
COMP_HEADER_LENGTH | final protected static int COMP_HEADER_LENGTH(Code) | | |
HEADER_LENGTH | final protected static int HEADER_LENGTH(Code) | | |
INITIAL_PACKET_SIZE | final protected static int INITIAL_PACKET_SIZE(Code) | | |
MAX_QUERY_SIZE_TO_EXPLAIN | final protected static int MAX_QUERY_SIZE_TO_EXPLAIN(Code) | | |
MAX_QUERY_SIZE_TO_LOG | final protected static int MAX_QUERY_SIZE_TO_LOG(Code) | | |
MIN_COMPRESS_LEN | final protected static int MIN_COMPRESS_LEN(Code) | | |
NULL_LENGTH | final protected static int NULL_LENGTH(Code) | | |
ZERO_DATETIME_VALUE_MARKER | final protected static String ZERO_DATETIME_VALUE_MARKER(Code) | | |
ZERO_DATE_VALUE_MARKER | final protected static String ZERO_DATE_VALUE_MARKER(Code) | | We need to have a 'marker' for all-zero datetimes so that ResultSet
can decide what to do based on connection setting
|
clientParam | protected long clientParam(Code) | | |
lastPacketSentTimeMs | protected long lastPacketSentTimeMs(Code) | | |
maxThreeBytes | protected int maxThreeBytes(Code) | | |
mysqlConnection | protected Socket mysqlConnection(Code) | | The connection to the server
|
serverCapabilities | protected int serverCapabilities(Code) | | |
serverCharsetIndex | protected int serverCharsetIndex(Code) | | |
MysqlIO | public MysqlIO(String host, int port, Properties props, String socketFactoryClassName, ConnectionImpl conn, int socketTimeout, int useBufferRowSizeThreshold) throws IOException, SQLException(Code) | | Constructor: Connect to the MySQL server and setup a stream connection.
Parameters: host - the hostname to connect to Parameters: port - the port number that the server is listening on Parameters: props - the Properties from DriverManager.getConnection() Parameters: socketFactoryClassName - the socket factory to use Parameters: conn - the Connection that is creating us Parameters: socketTimeout - the timeout to set for the socket (0 means notimeout) throws: IOException - if an IOException occurs during connect. throws: SQLException - if a database access error occurs. |
changeUser | protected void changeUser(String userName, String password, String database) throws SQLException(Code) | | Re-authenticates as the given user and password
Parameters: userName - DOCUMENT ME! Parameters: password - DOCUMENT ME! Parameters: database - DOCUMENT ME! throws: SQLException - DOCUMENT ME! |
checkErrorPacket | protected Buffer checkErrorPacket() throws SQLException(Code) | | Checks for errors in the reply packet, and if none, returns the reply
packet, ready for reading
a packet ready for reading. throws: SQLException - is the packet is an error packet |
checkForCharsetMismatch | protected void checkForCharsetMismatch()(Code) | | Determines if the database charset is the same as the platform charset
|
doHandshake | void doHandshake(String user, String password, String database) throws SQLException(Code) | | Initialize communications with the MySQL server. Handles logging on, and
handling initial connection errors.
Parameters: user - DOCUMENT ME! Parameters: password - DOCUMENT ME! Parameters: database - DOCUMENT ME! throws: SQLException - DOCUMENT ME! throws: CommunicationsException - DOCUMENT ME! |
explainSlowQuery | protected void explainSlowQuery(byte[] querySQL, String truncatedQuery) throws SQLException(Code) | | Runs an 'EXPLAIN' on the given query and dumps the results to the log
Parameters: querySQL - DOCUMENT ME! Parameters: truncatedQuery - DOCUMENT ME! throws: SQLException - DOCUMENT ME! |
fetchRowsViaCursor | protected List fetchRowsViaCursor(List fetchedRows, long statementId, Field[] columnTypes, int fetchSize, boolean useBufferRowExplicit) throws SQLException(Code) | | |
forceClose | final protected void forceClose()(Code) | | Forcibly closes the underlying socket to MySQL.
|
getCurrentTimeNanosOrMillis | protected long getCurrentTimeNanosOrMillis()(Code) | | |
getHost | String getHost()(Code) | | Returns the host this IO is connected to
DOCUMENT ME! |
getLastPacketSentTimeMs | protected long getLastPacketSentTimeMs()(Code) | | DOCUMENT ME!
Returns the lastPacketSentTimeMs. |
getMaxBuf | static int getMaxBuf()(Code) | | |
getQueryTimingUnits | protected String getQueryTimingUnits()(Code) | | |
getResultSet | protected ResultSetImpl getResultSet(StatementImpl callingStatement, long columnCount, int maxRows, int resultSetType, int resultSetConcurrency, boolean streamResults, String catalog, boolean isBinaryEncoded, Field[] metadataFromCache) throws SQLException(Code) | | Build a result set. Delegates to buildResultSetWithRows() to build a
JDBC-version-specific ResultSet, given rows as byte data, and field
information.
Parameters: callingStatement - DOCUMENT ME! Parameters: columnCount - the number of columns in the result set Parameters: maxRows - the maximum number of rows to read (-1 means all rows) Parameters: resultSetType - (TYPE_FORWARD_ONLY, TYPE_SCROLL_????) Parameters: resultSetConcurrency - the type of result set (CONCUR_UPDATABLE orREAD_ONLY) Parameters: streamResults - should the result set be read all at once, orstreamed? Parameters: catalog - the database name in use when the result set was created Parameters: isBinaryEncoded - is this result set in native encoding? Parameters: unpackFieldInfo - should we read MYSQL_FIELD info (if available)? a result set throws: SQLException - if a database access error occurs |
getServerMajorVersion | final int getServerMajorVersion()(Code) | | Get the major version of the MySQL server we are talking to.
DOCUMENT ME! |
getServerMinorVersion | final int getServerMinorVersion()(Code) | | Get the minor version of the MySQL server we are talking to.
DOCUMENT ME! |
getServerStatus | protected int getServerStatus()(Code) | | |
getServerSubMinorVersion | final int getServerSubMinorVersion()(Code) | | Get the sub-minor version of the MySQL server we are talking to.
DOCUMENT ME! |
getServerVersion | String getServerVersion()(Code) | | Get the version string of the server we are talking to
DOCUMENT ME! |
getSharedSendPacket | Buffer getSharedSendPacket()(Code) | | Returns the packet used for sending data (used by PreparedStatement)
Guarded by external synchronization on a mutex.
A packet to send data with |
getSlowQueryThreshold | protected long getSlowQueryThreshold()(Code) | | |
getThreadId | protected long getThreadId()(Code) | | |
hadWarnings | boolean hadWarnings()(Code) | | |
hasLongColumnInfo | public boolean hasLongColumnInfo()(Code) | | Does the server send back extra column info?
true if so |
inTransactionOnServer | protected boolean inTransactionOnServer()(Code) | | |
isSetNeededForAutoCommitMode | protected boolean isSetNeededForAutoCommitMode(boolean autoCommitFlag)(Code) | | |
isVersion | boolean isVersion(int major, int minor, int subminor)(Code) | | Is the version of the MySQL server we are connected to the given
version?
Parameters: major - the major version Parameters: minor - the minor version Parameters: subminor - the subminor version true if the version of the MySQL server we are connected is thegiven version |
nextRow | final ResultSetRow nextRow(Field[] fields, int columnCount, boolean isBinaryEncoded, int resultSetConcurrency, boolean useBufferRowIfPossible, boolean useBufferRowExplicit, boolean canReuseRowPacketForBufferRow, Buffer existingRowPacket) throws SQLException(Code) | | Retrieve one row from the MySQL server. Note: this method is not
thread-safe, but it is only called from methods that are guarded by
synchronizing on this object.
Parameters: fields - DOCUMENT ME! Parameters: columnCount - DOCUMENT ME! Parameters: isBinaryEncoded - DOCUMENT ME! Parameters: resultSetConcurrency - DOCUMENT ME! Parameters: b - DOCUMENT ME! throws: SQLException - DOCUMENT ME! |
nextRowFast | final ResultSetRow nextRowFast(Field[] fields, int columnCount, boolean isBinaryEncoded, int resultSetConcurrency, boolean useBufferRowIfPossible, boolean useBufferRowExplicit, boolean canReuseRowPacket) throws SQLException(Code) | | |
resetMaxBuf | void resetMaxBuf()(Code) | | Sets the buffer size to max-buf
|
resetReadPacketSequence | protected void resetReadPacketSequence()(Code) | | |
scanForAndThrowDataTruncation | void scanForAndThrowDataTruncation() throws SQLException(Code) | | |
secureAuth411 | void secureAuth411(Buffer packet, int packLength, String user, String password, String database, boolean writeClientParams) throws SQLException(Code) | | Secure authentication for 4.1.1 and newer servers.
Parameters: packet - DOCUMENT ME! Parameters: packLength - Parameters: user - Parameters: password - Parameters: database - DOCUMENT ME! Parameters: writeClientParams - throws: SQLException - |
sendCommand | final Buffer sendCommand(int command, String extraData, Buffer queryPacket, boolean skipCheck, String extraDataCharEncoding) throws SQLException(Code) | | Send a command to the MySQL server If data is to be sent with command,
it should be put in extraData.
Raw packets can be sent by setting queryPacket to something other
than null.
Parameters: command - the MySQL protocol 'command' from MysqlDefs Parameters: extraData - any 'string' data for the command Parameters: queryPacket - a packet pre-loaded with data for the protocol (i.e.from a client-side prepared statement). Parameters: skipCheck - do not call checkErrorPacket() if true Parameters: extraDataCharEncoding - the character encoding of the extraDataparameter. the response packet from the server throws: SQLException - if an I/O error or SQL error occurs |
skipPacket | final protected void skipPacket() throws SQLException(Code) | | Reads and discards a single MySQL packet from the input stream.
throws: SQLException - if the network fails while skipping thepacket. |
sqlQueryDirect | final ResultSetInternalMethods sqlQueryDirect(StatementImpl callingStatement, String query, String characterEncoding, Buffer queryPacket, int maxRows, int resultSetType, int resultSetConcurrency, boolean streamResults, String catalog, Field[] cachedMetadata) throws Exception(Code) | | Send a query stored in a packet directly to the server.
Parameters: callingStatement - DOCUMENT ME! Parameters: resultSetConcurrency - DOCUMENT ME! Parameters: characterEncoding - DOCUMENT ME! Parameters: queryPacket - DOCUMENT ME! Parameters: maxRows - DOCUMENT ME! Parameters: conn - DOCUMENT ME! Parameters: resultSetType - DOCUMENT ME! Parameters: resultSetConcurrency - DOCUMENT ME! Parameters: streamResults - DOCUMENT ME! Parameters: catalog - DOCUMENT ME! Parameters: unpackFieldInfo - should we read MYSQL_FIELD info (if available)? DOCUMENT ME! throws: Exception - DOCUMENT ME! |
unpackField | final protected Field unpackField(Buffer packet, boolean extractDefaultValues) throws SQLException(Code) | | Unpacks the Field information from the given packet. Understands pre 4.1
and post 4.1 server version field packet structures.
Parameters: packet - the packet containing the field information Parameters: extractDefaultValues - should default values be extracted? the unpacked field throws: SQLException - DOCUMENT ME! |
useBufferRowExplicit | public static boolean useBufferRowExplicit(Field[] fields)(Code) | | |
useNanosForElapsedTime | protected boolean useNanosForElapsedTime()(Code) | | |
versionMeetsMinimum | boolean versionMeetsMinimum(int major, int minor, int subminor)(Code) | | Does the version of the MySQL server we are connected to meet the given
minimums?
Parameters: major - DOCUMENT ME! Parameters: minor - DOCUMENT ME! Parameters: subminor - DOCUMENT ME! DOCUMENT ME! |
|
|