Save This Page
Home » MySQL-JDBC-5.1.11 » com.mysql.jdbc » [javadoc | source]
com.mysql.jdbc
class: MysqlIO [javadoc | source]
java.lang.Object
   com.mysql.jdbc.MysqlIO
This class is used by Connection for communicating with the MySQL server.
Field Summary
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 AUTH_411_OVERHEAD     
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     
static final  int SERVER_MORE_RESULTS_EXISTS     
protected static final  int MAX_QUERY_SIZE_TO_LOG     
protected static final  int MAX_QUERY_SIZE_TO_EXPLAIN     
protected static final  int INITIAL_PACKET_SIZE     
protected static final  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 final  String ZERO_DATETIME_VALUE_MARKER     
protected  int serverCharsetIndex     
protected  BufferedOutputStream mysqlOutput    Data to the server 
protected  ConnectionImpl connection     
protected  InputStream mysqlInput     
protected  Socket mysqlConnection    The connection to the server 
protected  String host     
protected  String seed     
protected  int maxThreeBytes     
protected  int port     
protected  int serverCapabilities     
protected  long clientParam     
protected  long lastPacketSentTimeMs     
protected  long lastPacketReceivedTimeMs     
Constructor:
 public MysqlIO(String host,
    int port,
    Properties props,
    String socketFactoryClassName,
    ConnectionImpl conn,
    int socketTimeout,
    int useBufferRowSizeThreshold) throws IOException, SQLException 
    Constructor: Connect to the MySQL server and setup a stream connection.
    Parameters:
    host - the hostname to connect to
    port - the port number that the server is listening on
    props - the Properties from DriverManager.getConnection()
    socketFactoryClassName - the socket factory to use
    conn - the Connection that is creating us
    socketTimeout - the timeout to set for the socket (0 means no timeout)
    Throws:
    IOException - if an IOException occurs during connect.
    SQLException - if a database access error occurs.
Method from com.mysql.jdbc.MysqlIO Summary:
changeUser,   checkErrorPacket,   checkForCharsetMismatch,   clearInputStream,   closeStreamer,   disableMultiQueries,   doHandshake,   dumpPacketRingBuffer,   enableMultiQueries,   explainSlowQuery,   fetchRowsViaCursor,   forceClose,   getCommandCount,   getCurrentTimeNanosOrMillis,   getExceptionInterceptor,   getHost,   getLastPacketReceivedTimeMs,   getLastPacketSentTimeMs,   getMaxBuf,   getQueryTimingUnits,   getResultSet,   getServerMajorVersion,   getServerMinorVersion,   getServerStatus,   getServerSubMinorVersion,   getServerVersion,   getSharedSendPacket,   getSlowQueryThreshold,   getThreadId,   hadWarnings,   hasLongColumnInfo,   inTransactionOnServer,   invokeStatementInterceptorsPost,   invokeStatementInterceptorsPre,   isDataAvailable,   isSetNeededForAutoCommitMode,   isVersion,   nextRow,   nextRowFast,   quit,   readAllResults,   readPacket,   readResultsForQueryOrUpdate,   resetMaxBuf,   resetReadPacketSequence,   scanForAndThrowDataTruncation,   secureAuth411,   sendCommand,   setStatementInterceptors,   shouldIntercept,   skipPacket,   sqlQueryDirect,   tackOnMoreStreamingResults,   unpackField,   useBufferRowExplicit,   useNanosForElapsedTime,   versionMeetsMinimum
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.mysql.jdbc.MysqlIO Detail:
 protected  void changeUser(String userName,
    String password,
    String database) throws SQLException 
    Re-authenticates as the given user and password
 protected Buffer checkErrorPacket() throws SQLException 
    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() throws SQLException 
  void closeStreamer(RowData streamer) throws SQLException 
  void disableMultiQueries() throws SQLException 
  void doHandshake(String user,
    String password,
    String database) throws SQLException 
    Initialize communications with the MySQL server. Handles logging on, and handling initial connection errors.
 protected  void dumpPacketRingBuffer() throws SQLException 
  void enableMultiQueries() throws SQLException 
 protected  void explainSlowQuery(byte[] querySQL,
    String truncatedQuery) throws SQLException 
    Runs an 'EXPLAIN' on the given query and dumps the results to the log
 protected List fetchRowsViaCursor(List fetchedRows,
    long statementId,
    Field[] columnTypes,
    int fetchSize,
    boolean useBufferRowExplicit) throws SQLException 
 protected final  void forceClose() 
    Forcibly closes the underlying socket to MySQL.
 protected int getCommandCount() 
 protected long getCurrentTimeNanosOrMillis() 
 protected ExceptionInterceptor getExceptionInterceptor() 
 String getHost() 
    Returns the host this IO is connected to
 protected long getLastPacketReceivedTimeMs() 
 protected long getLastPacketSentTimeMs() 
    DOCUMENT ME!
 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) throws SQLException 
    Build a result set. Delegates to buildResultSetWithRows() to build a JDBC-version-specific ResultSet, given rows as byte data, and field information.
 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() 
    Get the version string of the server we are talking to
 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() 
    Does the server send back extra column info?
 protected boolean inTransactionOnServer() 
 ResultSetInternalMethods invokeStatementInterceptorsPost(String sql,
    Statement interceptedStatement,
    ResultSetInternalMethods originalResultSet,
    boolean forceExecute,
    SQLException statementException) throws SQLException 
 ResultSetInternalMethods invokeStatementInterceptorsPre(String sql,
    Statement interceptedStatement,
    boolean forceExecute) throws SQLException 
 protected boolean isDataAvailable() throws SQLException 
 protected boolean isSetNeededForAutoCommitMode(boolean autoCommitFlag) 
 boolean isVersion(int major,
    int minor,
    int subminor) 
    Is the version of the MySQL server we are connected to the given version?
 final ResultSetRow nextRow(Field[] fields,
    int columnCount,
    boolean isBinaryEncoded,
    int resultSetConcurrency,
    boolean useBufferRowIfPossible,
    boolean useBufferRowExplicit,
    boolean canReuseRowPacketForBufferRow,
    Buffer existingRowPacket) throws SQLException 
    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.
 final ResultSetRow nextRowFast(Field[] fields,
    int columnCount,
    boolean isBinaryEncoded,
    int resultSetConcurrency,
    boolean useBufferRowIfPossible,
    boolean useBufferRowExplicit,
    boolean canReuseRowPacket) throws SQLException 
 final  void quit() throws SQLException 
    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) throws SQLException 
 protected final Buffer readPacket() throws SQLException 
    Read one packet from the MySQL server
 protected final ResultSetImpl readResultsForQueryOrUpdate(StatementImpl callingStatement,
    int maxRows,
    int resultSetType,
    int resultSetConcurrency,
    boolean streamResults,
    String catalog,
    Buffer resultPacket,
    boolean isBinaryEncoded,
    long preSentColumnCount,
    Field[] metadataFromCache) throws SQLException 
    Reads one result set off of the wire, if the result is actually an update count, creates an update-count only result set.
  void resetMaxBuf() 
    Sets the buffer size to max-buf
 protected  void resetReadPacketSequence() 
  void scanForAndThrowDataTruncation() throws SQLException 
  void secureAuth411(Buffer packet,
    int packLength,
    String user,
    String password,
    String database,
    boolean writeClientParams) throws SQLException 
    Secure authentication for 4.1.1 and newer servers.
 final Buffer sendCommand(int command,
    String extraData,
    Buffer queryPacket,
    boolean skipCheck,
    String extraDataCharEncoding,
    int timeoutMillis) throws SQLException 
    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.
 protected  void setStatementInterceptors(List statementInterceptors) 
 protected boolean shouldIntercept() 
 protected final  void skipPacket() throws SQLException 
    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) throws Exception 
    Send a query stored in a packet directly to the server.
 boolean tackOnMoreStreamingResults(ResultSetImpl addingTo) throws SQLException 
 protected final Field unpackField(Buffer packet,
    boolean extractDefaultValues) throws SQLException 
    Unpacks the Field information from the given packet. Understands pre 4.1 and post 4.1 server version field packet structures.
 public static boolean useBufferRowExplicit(Field[] fields) 
 protected boolean useNanosForElapsedTime() 
 boolean versionMeetsMinimum(int major,
    int minor,
    int subminor) 
    Does the version of the MySQL server we are connected to meet the given minimums?