Java Doc for MysqlIO.java in  » Database-JDBC-Connection-Pool » mysql-connector-java-5.1.3 » com » mysql » jdbc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » mysql connector java 5.1.3 » com.mysql.jdbc 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


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


Field Summary
final protected static  intAUTH_411_OVERHEAD
    
final protected static  intCLIENT_CONNECT_WITH_DB
    
final protected static  intCLIENT_RESERVED
    
final protected static  intCLIENT_SECURE_CONNECTION
    
final protected static  intCLIENT_SSL
    
final protected static  intCOMP_HEADER_LENGTH
    
final protected static  intHEADER_LENGTH
    
final protected static  intINITIAL_PACKET_SIZE
    
final protected static  intMAX_QUERY_SIZE_TO_EXPLAIN
    
final protected static  intMAX_QUERY_SIZE_TO_LOG
    
final protected static  intMIN_COMPRESS_LEN
    
final protected static  intNULL_LENGTH
    
final protected static  StringZERO_DATETIME_VALUE_MARKER
    
final protected static  StringZERO_DATE_VALUE_MARKER
    
protected  longclientParam
    
protected  ConnectionImplconnection
    
protected  Stringhost
    
protected  longlastPacketSentTimeMs
    
protected  intmaxThreeBytes
    
protected  SocketmysqlConnection
    
protected  InputStreammysqlInput
    
protected  BufferedOutputStreammysqlOutput
    
protected  intport
    
protected  Stringseed
    
protected  intserverCapabilities
    
protected  intserverCharsetIndex
    

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  voidchangeUser(String userName, String password, String database)
    
protected  BuffercheckErrorPacket()
    
protected  voidcheckForCharsetMismatch()
    
protected  voidclearInputStream()
    
 voidcloseStreamer(RowData streamer)
    
 voiddisableMultiQueries()
    
 voiddoHandshake(String user, String password, String database)
     Initialize communications with the MySQL server.
protected  voiddumpPacketRingBuffer()
    
 voidenableMultiQueries()
    
protected  voidexplainSlowQuery(byte[] querySQL, String truncatedQuery)
    
protected  ListfetchRowsViaCursor(List fetchedRows, long statementId, Field[] columnTypes, int fetchSize, boolean useBufferRowExplicit)
    
final protected  voidforceClose()
     Forcibly closes the underlying socket to MySQL.
protected  longgetCurrentTimeNanosOrMillis()
    
 StringgetHost()
    
protected  longgetLastPacketSentTimeMs()
    
static  intgetMaxBuf()
    
protected  StringgetQueryTimingUnits()
    
protected  ResultSetImplgetResultSet(StatementImpl callingStatement, long columnCount, int maxRows, int resultSetType, int resultSetConcurrency, boolean streamResults, String catalog, boolean isBinaryEncoded, Field[] metadataFromCache)
     Build a result set.
final  intgetServerMajorVersion()
     Get the major version of the MySQL server we are talking to.
final  intgetServerMinorVersion()
     Get the minor version of the MySQL server we are talking to.
protected  intgetServerStatus()
    
final  intgetServerSubMinorVersion()
     Get the sub-minor version of the MySQL server we are talking to.
 StringgetServerVersion()
    
 BuffergetSharedSendPacket()
     Returns the packet used for sending data (used by PreparedStatement) Guarded by external synchronization on a mutex.
protected  longgetSlowQueryThreshold()
    
protected  longgetThreadId()
    
 booleanhadWarnings()
    
public  booleanhasLongColumnInfo()
    
protected  booleaninTransactionOnServer()
    
protected  voidinitializeStatementInterceptors(String interceptorClasses, Properties props)
    
protected  booleanisDataAvailable()
    
protected  booleanisSetNeededForAutoCommitMode(boolean autoCommitFlag)
    
 booleanisVersion(int major, int minor, int subminor)
    
final  ResultSetRownextRow(Field[] fields, int columnCount, boolean isBinaryEncoded, int resultSetConcurrency, boolean useBufferRowIfPossible, boolean useBufferRowExplicit, boolean canReuseRowPacketForBufferRow, Buffer existingRowPacket)
     Retrieve one row from the MySQL server.
final  ResultSetRownextRowFast(Field[] fields, int columnCount, boolean isBinaryEncoded, int resultSetConcurrency, boolean useBufferRowIfPossible, boolean useBufferRowExplicit, boolean canReuseRowPacket)
    
final  voidquit()
     Log-off of the MySQL server and close the socket.
 ResultSetImplreadAllResults(StatementImpl callingStatement, int maxRows, int resultSetType, int resultSetConcurrency, boolean streamResults, String catalog, Buffer resultPacket, boolean isBinaryEncoded, long preSentColumnCount, Field[] metadataFromCache)
    
final protected  BufferreadPacket()
    
 voidresetMaxBuf()
    
protected  voidresetReadPacketSequence()
    
 voidscanForAndThrowDataTruncation()
    
 voidsecureAuth411(Buffer packet, int packLength, String user, String password, String database, boolean writeClientParams)
     Secure authentication for 4.1.1 and newer servers.
final  BuffersendCommand(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  voidskipPacket()
     Reads and discards a single MySQL packet from the input stream.
final  ResultSetInternalMethodssqlQueryDirect(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  FieldunpackField(Buffer packet, boolean extractDefaultValues)
     Unpacks the Field information from the given packet.
public static  booleanuseBufferRowExplicit(Field[] fields)
    
protected  booleanuseNanosForElapsedTime()
    
 booleanversionMeetsMinimum(int major, int minor, int subminor)
    

Field Detail
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)



connection
protected ConnectionImpl connection(Code)



host
protected String host(Code)



lastPacketSentTimeMs
protected long lastPacketSentTimeMs(Code)



maxThreeBytes
protected int maxThreeBytes(Code)



mysqlConnection
protected Socket mysqlConnection(Code)
The connection to the server



mysqlInput
protected InputStream mysqlInput(Code)



mysqlOutput
protected BufferedOutputStream mysqlOutput(Code)
Data to the server



port
protected int port(Code)



seed
protected String seed(Code)



serverCapabilities
protected int serverCapabilities(Code)



serverCharsetIndex
protected int serverCharsetIndex(Code)




Constructor Detail
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.




Method Detail
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



clearInputStream
protected void clearInputStream() throws SQLException(Code)



closeStreamer
void closeStreamer(RowData streamer) throws SQLException(Code)



disableMultiQueries
void disableMultiQueries() throws SQLException(Code)



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!



dumpPacketRingBuffer
protected void dumpPacketRingBuffer() throws SQLException(Code)



enableMultiQueries
void enableMultiQueries() throws SQLException(Code)



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)



initializeStatementInterceptors
protected void initializeStatementInterceptors(String interceptorClasses, Properties props) throws SQLException(Code)



isDataAvailable
protected boolean isDataAvailable() throws SQLException(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)



quit
final void quit() throws SQLException(Code)
Log-off of the MySQL server and close the socket.
throws:
  SQLException - DOCUMENT ME!



readAllResults
ResultSetImpl readAllResults(StatementImpl callingStatement, int maxRows, int resultSetType, int resultSetConcurrency, boolean streamResults, String catalog, Buffer resultPacket, boolean isBinaryEncoded, long preSentColumnCount, Field[] metadataFromCache) throws SQLException(Code)



readPacket
final protected Buffer readPacket() throws SQLException(Code)
Read one packet from the MySQL server the packet from the server.
throws:
  SQLException - DOCUMENT ME!
throws:
  CommunicationsException - DOCUMENT ME!



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!



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.