com.mysql.jdbc
Class Connection

java.lang.Object
  extended bycom.mysql.jdbc.Connection
All Implemented Interfaces:
java.sql.Connection

public class Connection
extends java.lang.Object
implements java.sql.Connection

A Connection represents a session with a specific database. Within the context of a Connection, SQL statements are executed and results are returned.

A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc. This information is obtained with the getMetaData method.

See Also:
Connection

Nested Class Summary
(package private)  class Connection.UltraDevWorkAround
          Wrapper class for UltraDev CallableStatements that are really PreparedStatments.
 
Field Summary
(package private)  boolean parserKnowsUnicode
           
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
(package private) Connection(java.lang.String host, int port, java.util.Properties info, java.lang.String database, java.lang.String url, NonRegisteringDriver d)
          Creates a connection to a MySQL Server.
 
Method Summary
 boolean allowLoadLocalInfile()
          Allow use of LOAD LOCAL INFILE?
(package private)  boolean alwaysClearStream()
           
 boolean capitalizeDBMDTypes()
          DOCUMENT ME!
 void changeUser(java.lang.String userName, java.lang.String newPassword)
          Changes the user on this connection by performing a re-authentication.
 void clearWarnings()
          After this call, getWarnings returns null until a new warning is reported for this connection.
 void close()
          In some cases, it is desirable to immediately release a Connection's database and JDBC resources instead of waiting for them to be automatically released (cant think why off the top of my head) Note: A Connection is automatically closed when it is garbage collected.
 void commit()
          The method commit() makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection.
(package private)  boolean continueBatchOnError()
           
protected  MysqlIO createNewIO(boolean isForReconnect)
          Creates an IO channel to the server
 java.sql.Statement createStatement()
          SQL statements without parameters are normally executed using Statement objects.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
          JDBC 2.0 Same as createStatement() above, but allows the default result set type and result set concurrency type to be overridden.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
           
(package private)  ResultSet execSQL(java.lang.String sql, int maxRows, Buffer packet, int resultSetType, boolean streamResults, boolean queryIsSelectOnly, java.lang.String catalog)
           
(package private)  ResultSet execSQL(java.lang.String sql, int maxRows, Buffer packet, int resultSetType, java.lang.String catalog)
           
(package private)  ResultSet execSQL(java.lang.String sql, int maxRows, Buffer packet, java.lang.String catalog)
           
(package private)  ResultSet execSQL(java.lang.String sql, int maxRows, int resultSetType, boolean streamResults, boolean queryIsSelectOnly, java.lang.String catalog)
           
(package private)  ResultSet execSQL(java.lang.String sql, int maxRowsToRetreive, java.lang.String catalog)
          Send a query to the server.
protected  void finalize()
          Cleanup the connection.
 boolean getAutoCommit()
          gets the current auto-commit state
 java.lang.String getCatalog()
          Return the connections current catalog name, or null if no catalog name is set, or we dont support catalogs.
protected  java.lang.String getCharacterSetMetadata()
           
(package private)  SingleByteCharsetConverter getCharsetConverter(java.lang.String javaEncodingName)
          Returns the locally mapped instance of a charset converter (to avoid overhead of static synchronization).
protected  java.lang.String getCharsetNameForIndex(int charsetIndex)
          Returns the Java character encoding name for the given MySQL server charset index
 boolean getClobberStreamingResults()
          Returns whether we clobber streaming results on new queries, or issue an error?
protected  java.util.TimeZone getDefaultTimeZone()
          DOCUMENT ME!
 java.lang.String getEncoding()
          Returns the character encoding for this Connection
 int getHoldability()
           
 long getIdleFor()
          NOT JDBC-Compliant, but clients can use this method to determine how long this connection has been idle.
protected  MysqlIO getIO()
          Returns the IO channel to the server
(package private)  int getMaxAllowedPacket()
          Returns the maximum packet size the MySQL server will accept
(package private)  int getMaxRows()
          DOCUMENT ME!
 java.sql.DatabaseMetaData getMetaData()
          A connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc.
(package private)  java.lang.Object getMutex()
          Returns the Mutex all queries are locked against
 java.lang.String getNegativeInfinityRep()
          DOCUMENT ME!
(package private)  int getNetBufferLength()
          Returns the packet buffer size the MySQL server reported upon connection
protected  int getNetWriteTimeout()
           
 java.lang.String getNotANumberRep()
          DOCUMENT ME!
 java.lang.String getPositiveInfinityRep()
          DOCUMENT ME!
 boolean getRollbackOnPooledClose()
           
protected  java.lang.String getServerCharacterEncoding()
          Returns the server's character set
(package private)  int getServerMajorVersion()
           
(package private)  int getServerMinorVersion()
           
(package private)  int getServerSubMinorVersion()
           
 java.util.TimeZone getServerTimezone()
          DOCUMENT ME!
(package private)  java.lang.String getServerVersion()
           
 boolean getTinyint1isBit()
           
 int getTransactionIsolation()
          Get this Connection's current transaction isolation mode.
 java.util.Map getTypeMap()
          JDBC 2.0 Get the type-map object associated with this connection.
(package private)  java.lang.String getURL()
           
protected  boolean getUseOnlyServerErrorMessages()
           
(package private)  java.lang.String getUser()
           
 java.sql.SQLWarning getWarnings()
          The first warning reported by calls on this Connection is returned.
 boolean isClosed()
          DOCUMENT ME!
 boolean isInteractiveClient()
          Should we tell MySQL that we're an interactive client
 boolean isNegativeInfinityRepIsClipped()
          DOCUMENT ME!
 boolean isNotANumberRepIsClipped()
          DOCUMENT ME!
(package private)  boolean isPedantic()
           
 boolean isPositiveInfinityRepIsClipped()
          DOCUMENT ME!
(package private)  boolean isReadInfoMsgEnabled()
           
 boolean isReadOnly()
          Tests to see if the connection is in Read Only Mode.
protected  boolean isUsingUnbufferedInput()
          Is this connection using unbuffered input?
 boolean lowerCaseTableNames()
          Is the server configured to use lower-case table names only?
(package private)  void maxRowsChanged(Statement stmt)
          Has the maxRows value changed?
 java.lang.String nativeSQL(java.lang.String sql)
          A driver may convert the JDBC sql grammar into its system's native SQL grammar prior to sending it; nativeSQL returns the native form of the statement that the driver would have sent.
 boolean parserKnowsUnicode()
          DOCUMENT ME!
 java.sql.CallableStatement prepareCall(java.lang.String sql)
          DOCUMENT ME!
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          JDBC 2.0 Same as prepareCall() above, but allows the default result set type and result set concurrency type to be overridden.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGenKeyIndex)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] autoGenKeyIndexes)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          JDBC 2.0 Same as prepareStatement() above, but allows the default result set type and result set concurrency type to be overridden.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] autoGenKeyColNames)
           
protected  void realClose(boolean calledExplicitly, boolean issueRollback)
          Closes connection and frees resources.
 void releaseSavepoint(java.sql.Savepoint arg0)
           
 void resetServerState()
          Resets the server-side state of this connection.
 void rollback()
          The method rollback() drops all changes made since the previous commit/rollback and releases any database locks currently held by the Connection.
 void rollback(java.sql.Savepoint arg0)
           
 void setAutoCommit(boolean autoCommit)
          If a connection is in auto-commit mode, than all its SQL statements will be executed and committed as individual transactions.
 void setCatalog(java.lang.String catalog)
          A sub-space of this Connection's database may be selected by setting a catalog name.
 void setHoldability(int arg0)
           
 void setProfileSql(boolean flag)
          Should the driver do profiling?
(package private)  void setReadInfoMsgEnabled(boolean flag)
           
 void setReadOnly(boolean readOnly)
          You can put a connection in read-only mode as a hint to enable database optimizations Note: setReadOnly cannot be called while in the middle of a transaction
 java.sql.Savepoint setSavepoint()
           
 java.sql.Savepoint setSavepoint(java.lang.String arg0)
           
 void setTransactionIsolation(int level)
          DOCUMENT ME!
 void setTypeMap(java.util.Map map)
          JDBC 2.0 Install a type-map object as the default type-map for this connection
(package private)  void setUseSSL(boolean flag)
          Set whether or not this connection should use SSL
 void shutdownServer()
          Used by MiniAdmin to shutdown a MySQL server
 boolean supportsIsolationLevel()
          DOCUMENT ME!
 boolean supportsQuotedIdentifiers()
          DOCUMENT ME!
 boolean supportsTransactions()
          DOCUMENT ME!
(package private)  void unsetMaxRows(Statement stmt)
          Called by statements on their .close() to let the connection know when it is safe to set the connection back to 'default' row limits.
(package private)  boolean useAnsiQuotedIdentifiers()
           
 boolean useCompression()
          Should we use compression?
(package private)  boolean useHostsInPrivileges()
           
(package private)  boolean useMaxRows()
          Has maxRows() been set?
 boolean useParanoidErrorMessages()
          Returns the paranoidErrorMessages.
 boolean useSSL()
          Should we use SSL?
(package private)  boolean useStreamLengthsInPrepStmts()
           
 boolean useStrictFloatingPoint()
          Should we enable work-arounds for floating point rounding errors in the server?
 boolean useStrictUpdates()
          Returns the strictUpdates value.
 boolean useTimezone()
          DOCUMENT ME!
 boolean useUnicode()
          Should unicode character mapping be used ?
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parserKnowsUnicode

boolean parserKnowsUnicode
Constructor Detail

Connection

Connection(java.lang.String host,
           int port,
           java.util.Properties info,
           java.lang.String database,
           java.lang.String url,
           NonRegisteringDriver d)
     throws java.sql.SQLException
Creates a connection to a MySQL Server.

Parameters:
host - the hostname of the database server
port - the port number the server is listening on
info - a Properties[] list holding the user and password
database - the database to connect to
url - the URL of the connection
d - the Driver instantation of the connection
Throws:
java.sql.SQLException - if a database access error occurs
java.sql.SQLException - DOCUMENT ME!
Method Detail

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws java.sql.SQLException
If a connection is in auto-commit mode, than all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by either commit() or rollback(). By default, new connections are in auto- commit mode. The commit occurs when the statement completes or the next execute occurs, whichever comes first. In the case of statements returning a ResultSet, the statement completes when the last row of the ResultSet has been retrieved or the ResultSet has been closed. In advanced cases, a single statement may return multiple results as well as output parameter values. Here the commit occurs when all results and output param values have been retrieved.

Note: MySQL does not support transactions, so this method is a no-op.

Specified by:
setAutoCommit in interface java.sql.Connection
Parameters:
autoCommit - - true enables auto-commit; false disables it
Throws:
java.sql.SQLException - if a database access error occurs
java.sql.SQLException - DOCUMENT ME!

getAutoCommit

public boolean getAutoCommit()
                      throws java.sql.SQLException
gets the current auto-commit state

Specified by:
getAutoCommit in interface java.sql.Connection
Returns:
Current state of the auto-commit mode
Throws:
java.sql.SQLException - (why?)
See Also:
setAutoCommit

setCatalog

public void setCatalog(java.lang.String catalog)
                throws java.sql.SQLException
A sub-space of this Connection's database may be selected by setting a catalog name. If the driver does not support catalogs, it will silently ignore this request

Note: MySQL's notion of catalogs are individual databases.

Specified by:
setCatalog in interface java.sql.Connection
Parameters:
catalog - the database for this connection to use
Throws:
java.sql.SQLException - if a database access error occurs

getCatalog

public java.lang.String getCatalog()
                            throws java.sql.SQLException
Return the connections current catalog name, or null if no catalog name is set, or we dont support catalogs.

Note: MySQL's notion of catalogs are individual databases.

Specified by:
getCatalog in interface java.sql.Connection
Returns:
the current catalog name or null
Throws:
java.sql.SQLException - if a database access error occurs

getClobberStreamingResults

public boolean getClobberStreamingResults()
Returns whether we clobber streaming results on new queries, or issue an error?

Returns:
true if we should implicitly close streaming result sets upon receiving a new query

isClosed

public boolean isClosed()
DOCUMENT ME!

Specified by:
isClosed in interface java.sql.Connection
Returns:
DOCUMENT ME!

getEncoding

public java.lang.String getEncoding()
Returns the character encoding for this Connection

Returns:
the character encoding for this connection.

setHoldability

public void setHoldability(int arg0)
                    throws java.sql.SQLException
Specified by:
setHoldability in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
setHoldability(int)

getHoldability

public int getHoldability()
                   throws java.sql.SQLException
Specified by:
getHoldability in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
getHoldability()

getIdleFor

public long getIdleFor()
NOT JDBC-Compliant, but clients can use this method to determine how long this connection has been idle. This time (reported in milliseconds) is updated once a query has completed.

Returns:
number of ms that this connection has been idle, 0 if the driver is busy retrieving results.

isInteractiveClient

public boolean isInteractiveClient()
Should we tell MySQL that we're an interactive client

Returns:
true if isInteractiveClient was set to true.

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws java.sql.SQLException
A connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc. This information is made available through a DatabaseMetaData object.

Specified by:
getMetaData in interface java.sql.Connection
Returns:
a DatabaseMetaData object for this connection
Throws:
java.sql.SQLException - if a database access error occurs

getNegativeInfinityRep

public java.lang.String getNegativeInfinityRep()
DOCUMENT ME!

Returns:

isNegativeInfinityRepIsClipped

public boolean isNegativeInfinityRepIsClipped()
DOCUMENT ME!

Returns:

getNotANumberRep

public java.lang.String getNotANumberRep()
DOCUMENT ME!

Returns:

isNotANumberRepIsClipped

public boolean isNotANumberRepIsClipped()
DOCUMENT ME!

Returns:

getPositiveInfinityRep

public java.lang.String getPositiveInfinityRep()
DOCUMENT ME!

Returns:

isPositiveInfinityRepIsClipped

public boolean isPositiveInfinityRepIsClipped()
DOCUMENT ME!

Returns:

setProfileSql

public void setProfileSql(boolean flag)
                   throws java.sql.SQLException
Should the driver do profiling?

Parameters:
flag - set to true to enable profiling.
Throws:
java.sql.SQLException - if the connection is closed.

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws java.sql.SQLException
You can put a connection in read-only mode as a hint to enable database optimizations Note: setReadOnly cannot be called while in the middle of a transaction

Specified by:
setReadOnly in interface java.sql.Connection
Parameters:
readOnly - - true enables read-only mode; false disables it
Throws:
java.sql.SQLException - if a database access error occurs

isReadOnly

public boolean isReadOnly()
                   throws java.sql.SQLException
Tests to see if the connection is in Read Only Mode. Note that we cannot really put the database in read only mode, but we pretend we can by returning the value of the readOnly flag

Specified by:
isReadOnly in interface java.sql.Connection
Returns:
true if the connection is read only
Throws:
java.sql.SQLException - if a database access error occurs

setSavepoint

public java.sql.Savepoint setSavepoint()
                                throws java.sql.SQLException
Specified by:
setSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
setSavepoint()

setSavepoint

public java.sql.Savepoint setSavepoint(java.lang.String arg0)
                                throws java.sql.SQLException
Specified by:
setSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
setSavepoint(String)

getServerTimezone

public java.util.TimeZone getServerTimezone()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws java.sql.SQLException
DOCUMENT ME!

Specified by:
setTransactionIsolation in interface java.sql.Connection
Parameters:
level - DOCUMENT ME!
Throws:
java.sql.SQLException - DOCUMENT ME!
java.sql.SQLException - DOCUMENT ME!

getTransactionIsolation

public int getTransactionIsolation()
                            throws java.sql.SQLException
Get this Connection's current transaction isolation mode.

Specified by:
getTransactionIsolation in interface java.sql.Connection
Returns:
the current TRANSACTION_ mode value
Throws:
java.sql.SQLException - if a database access error occurs
java.sql.SQLException - DOCUMENT ME!

setTypeMap

public void setTypeMap(java.util.Map map)
                throws java.sql.SQLException
JDBC 2.0 Install a type-map object as the default type-map for this connection

Specified by:
setTypeMap in interface java.sql.Connection
Parameters:
map - the type mapping
Throws:
java.sql.SQLException - if a database error occurs.

getTypeMap

public java.util.Map getTypeMap()
                         throws java.sql.SQLException
JDBC 2.0 Get the type-map object associated with this connection. By default, the map returned is empty.

Specified by:
getTypeMap in interface java.sql.Connection
Returns:
the type map
Throws:
java.sql.SQLException - if a database error occurs

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
The first warning reported by calls on this Connection is returned. Note: Sebsequent warnings will be changed to this java.sql.SQLWarning

Specified by:
getWarnings in interface java.sql.Connection
Returns:
the first java.sql.SQLWarning or null
Throws:
java.sql.SQLException - if a database access error occurs

allowLoadLocalInfile

public boolean allowLoadLocalInfile()
Allow use of LOAD LOCAL INFILE?

Returns:
true if allowLoadLocalInfile was set to true.

capitalizeDBMDTypes

public boolean capitalizeDBMDTypes()
DOCUMENT ME!

Returns:
DOCUMENT ME!

changeUser

public void changeUser(java.lang.String userName,
                       java.lang.String newPassword)
                throws java.sql.SQLException
Changes the user on this connection by performing a re-authentication. If authentication fails, the connection will remain under the context of the current user.

Parameters:
userName - the username to authenticate with
newPassword - the password to authenticate with
Throws:
java.sql.SQLException - if authentication fails, or some other error occurs while performing the command.

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
After this call, getWarnings returns null until a new warning is reported for this connection.

Specified by:
clearWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException - if a database access error occurs

close

public void close()
           throws java.sql.SQLException
In some cases, it is desirable to immediately release a Connection's database and JDBC resources instead of waiting for them to be automatically released (cant think why off the top of my head) Note: A Connection is automatically closed when it is garbage collected. Certain fatal errors also result in a closed connection.

Specified by:
close in interface java.sql.Connection
Throws:
java.sql.SQLException - if a database access error occurs

commit

public void commit()
            throws java.sql.SQLException
The method commit() makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection. This method should only be used when auto-commit has been disabled.

Specified by:
commit in interface java.sql.Connection
Throws:
java.sql.SQLException - if a database access error occurs
See Also:
setAutoCommit

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency)
                                   throws java.sql.SQLException
JDBC 2.0 Same as createStatement() above, but allows the default result set type and result set concurrency type to be overridden.

Specified by:
createStatement in interface java.sql.Connection
Parameters:
resultSetType - a result set type, see ResultSet.TYPE_XXX
resultSetConcurrency - a concurrency type, see ResultSet.CONCUR_XXX
Returns:
a new Statement object
Throws:
java.sql.SQLException - if a database-access error occurs.

createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException
SQL statements without parameters are normally executed using Statement objects. If the same SQL statement is executed many times, it is more efficient to use a PreparedStatement

Specified by:
createStatement in interface java.sql.Connection
Returns:
a new Statement object
Throws:
java.sql.SQLException - passed through from the constructor

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
                                   throws java.sql.SQLException
Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
createStatement(int, int, int)

finalize

protected void finalize()
                 throws java.lang.Throwable
Cleanup the connection.

Throws:
java.lang.Throwable - if an error occurs during cleanup.

lowerCaseTableNames

public boolean lowerCaseTableNames()
Is the server configured to use lower-case table names only?

Returns:
true if lower_case_table_names is 'on'

nativeSQL

public java.lang.String nativeSQL(java.lang.String sql)
                           throws java.sql.SQLException
A driver may convert the JDBC sql grammar into its system's native SQL grammar prior to sending it; nativeSQL returns the native form of the statement that the driver would have sent.

Specified by:
nativeSQL in interface java.sql.Connection
Parameters:
sql - a SQL statement that may contain one or more '?' parameter placeholders
Returns:
the native form of this statement
Throws:
java.sql.SQLException - if a database access error occurs

parserKnowsUnicode

public boolean parserKnowsUnicode()
DOCUMENT ME!

Returns:
DOCUMENT ME!

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
DOCUMENT ME!

Specified by:
prepareCall in interface java.sql.Connection
Parameters:
sql - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.sql.SQLException - DOCUMENT ME!

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int resultSetType,
                                              int resultSetConcurrency)
                                       throws java.sql.SQLException
JDBC 2.0 Same as prepareCall() above, but allows the default result set type and result set concurrency type to be overridden.

Specified by:
prepareCall in interface java.sql.Connection
Parameters:
sql - the SQL representing the callable statement
resultSetType - a result set type, see ResultSet.TYPE_XXX
resultSetConcurrency - a concurrency type, see ResultSet.CONCUR_XXX
Returns:
a new CallableStatement object containing the pre-compiled SQL statement
Throws:
java.sql.SQLException - if a database-access error occurs.

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int resultSetType,
                                              int resultSetConcurrency,
                                              int resultSetHoldability)
                                       throws java.sql.SQLException
Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
prepareCall(String, int, int, int)

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.

Note: This method is optimized for handling parametric SQL statements that benefit from precompilation if the driver supports precompilation. In this case, the statement is not sent to the database until the PreparedStatement is executed. This has no direct effect on users; however it does affect which method throws certain java.sql.SQLExceptions

MySQL does not support precompilation of statements, so they are handled by the driver.

Specified by:
prepareStatement in interface java.sql.Connection
Parameters:
sql - a SQL statement that may contain one or more '?' IN parameter placeholders
Returns:
a new PreparedStatement object containing the pre-compiled statement.
Throws:
java.sql.SQLException - if a database access error occurs.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency)
                                            throws java.sql.SQLException
JDBC 2.0 Same as prepareStatement() above, but allows the default result set type and result set concurrency type to be overridden.

Specified by:
prepareStatement in interface java.sql.Connection
Parameters:
sql - the SQL query containing place holders
resultSetType - a result set type, see ResultSet.TYPE_XXX
resultSetConcurrency - a concurrency type, see ResultSet.CONCUR_XXX
Returns:
a new PreparedStatement object containing the pre-compiled SQL statement
Throws:
java.sql.SQLException - if a database-access error occurs.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency,
                                                   int resultSetHoldability)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
prepareStatement(String, int, int, int)

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int autoGenKeyIndex)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
prepareStatement(String, int)

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int[] autoGenKeyIndexes)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
prepareStatement(String, int[])

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   java.lang.String[] autoGenKeyColNames)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
prepareStatement(String, String[])

releaseSavepoint

public void releaseSavepoint(java.sql.Savepoint arg0)
                      throws java.sql.SQLException
Specified by:
releaseSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
releaseSavepoint(Savepoint)

resetServerState

public void resetServerState()
                      throws java.sql.SQLException
Resets the server-side state of this connection. Doesn't work for MySQL versions older than 4.0.6 or if isParanoid() is set (it will become a no-op in these cases). Usually only used from connection pooling code.

Throws:
java.sql.SQLException - if the operation fails while resetting server state.

rollback

public void rollback()
              throws java.sql.SQLException
The method rollback() drops all changes made since the previous commit/rollback and releases any database locks currently held by the Connection.

Specified by:
rollback in interface java.sql.Connection
Throws:
java.sql.SQLException - if a database access error occurs
java.sql.SQLException - DOCUMENT ME!
See Also:
commit

rollback

public void rollback(java.sql.Savepoint arg0)
              throws java.sql.SQLException
Specified by:
rollback in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
rollback(Savepoint)

shutdownServer

public void shutdownServer()
                    throws java.sql.SQLException
Used by MiniAdmin to shutdown a MySQL server

Throws:
java.sql.SQLException - if the command can not be issued.

supportsIsolationLevel

public boolean supportsIsolationLevel()
DOCUMENT ME!

Returns:
DOCUMENT ME!

supportsQuotedIdentifiers

public boolean supportsQuotedIdentifiers()
DOCUMENT ME!

Returns:
DOCUMENT ME!

supportsTransactions

public boolean supportsTransactions()
DOCUMENT ME!

Returns:
DOCUMENT ME!

useCompression

public boolean useCompression()
Should we use compression?

Returns:
should we use compression to communicate with the server?

useParanoidErrorMessages

public boolean useParanoidErrorMessages()
Returns the paranoidErrorMessages.

Returns:
boolean if we should be paranoid about error messages.

useSSL

public boolean useSSL()
Should we use SSL?

Returns:
should we use SSL to communicate with the server?

useStrictFloatingPoint

public boolean useStrictFloatingPoint()
Should we enable work-arounds for floating point rounding errors in the server?

Returns:
should we use floating point work-arounds?

useStrictUpdates

public boolean useStrictUpdates()
Returns the strictUpdates value.

Returns:
boolean

useTimezone

public boolean useTimezone()
DOCUMENT ME!

Returns:
DOCUMENT ME!

useUnicode

public boolean useUnicode()
Should unicode character mapping be used ?

Returns:
should we use Unicode character mapping?

getCharsetNameForIndex

protected java.lang.String getCharsetNameForIndex(int charsetIndex)
                                           throws java.sql.SQLException
Returns the Java character encoding name for the given MySQL server charset index

Parameters:
charsetIndex -
Returns:
the Java character encoding name for the given MySQL server charset index
Throws:
java.sql.SQLException - if the character set index isn't known by the driver

getDefaultTimeZone

protected java.util.TimeZone getDefaultTimeZone()
DOCUMENT ME!

Returns:
Returns the defaultTimeZone.

getIO

protected MysqlIO getIO()
                 throws java.sql.SQLException
Returns the IO channel to the server

Returns:
the IO channel to the server
Throws:
java.sql.SQLException - if the connection is closed.

getNetWriteTimeout

protected int getNetWriteTimeout()

isUsingUnbufferedInput

protected boolean isUsingUnbufferedInput()
Is this connection using unbuffered input?

Returns:
whether or not to use buffered input streams

createNewIO

protected MysqlIO createNewIO(boolean isForReconnect)
                       throws java.sql.SQLException
Creates an IO channel to the server

Parameters:
isForReconnect - is this request for a re-connect
Returns:
a new MysqlIO instance connected to a server
Throws:
java.sql.SQLException - if a database access error occurs

realClose

protected void realClose(boolean calledExplicitly,
                         boolean issueRollback)
                  throws java.sql.SQLException
Closes connection and frees resources.

Parameters:
calledExplicitly - is this being called from close()
issueRollback - should a rollback() be issued?
Throws:
java.sql.SQLException - if an error occurs

getCharsetConverter

SingleByteCharsetConverter getCharsetConverter(java.lang.String javaEncodingName)
Returns the locally mapped instance of a charset converter (to avoid overhead of static synchronization).

Parameters:
javaEncodingName - the encoding name to retrieve
Returns:
a character converter, or null if one couldn't be mapped.

getMaxAllowedPacket

int getMaxAllowedPacket()
Returns the maximum packet size the MySQL server will accept

Returns:
DOCUMENT ME!

getMaxRows

int getMaxRows()
DOCUMENT ME!

Returns:
the max rows to return for statements (by default)

getMutex

java.lang.Object getMutex()
                    throws java.sql.SQLException
Returns the Mutex all queries are locked against

Returns:
DOCUMENT ME!
Throws:
java.sql.SQLException - DOCUMENT ME!

getNetBufferLength

int getNetBufferLength()
Returns the packet buffer size the MySQL server reported upon connection

Returns:
DOCUMENT ME!

isPedantic

boolean isPedantic()

setReadInfoMsgEnabled

void setReadInfoMsgEnabled(boolean flag)

isReadInfoMsgEnabled

boolean isReadInfoMsgEnabled()

getServerMajorVersion

int getServerMajorVersion()

getServerMinorVersion

int getServerMinorVersion()

getServerSubMinorVersion

int getServerSubMinorVersion()

getServerVersion

java.lang.String getServerVersion()

getURL

java.lang.String getURL()

setUseSSL

void setUseSSL(boolean flag)
Set whether or not this connection should use SSL

Parameters:
flag - DOCUMENT ME!

getUser

java.lang.String getUser()

alwaysClearStream

boolean alwaysClearStream()

continueBatchOnError

boolean continueBatchOnError()

execSQL

ResultSet execSQL(java.lang.String sql,
                  int maxRowsToRetreive,
                  java.lang.String catalog)
            throws java.sql.SQLException
Send a query to the server. Returns one of the ResultSet objects. This is synchronized, so Statement's queries will be serialized.

Parameters:
sql - the SQL statement to be executed
maxRowsToRetreive - DOCUMENT ME!
catalog - DOCUMENT ME!
Returns:
a ResultSet holding the results
Throws:
java.sql.SQLException - if a database error occurs

execSQL

ResultSet execSQL(java.lang.String sql,
                  int maxRows,
                  int resultSetType,
                  boolean streamResults,
                  boolean queryIsSelectOnly,
                  java.lang.String catalog)
            throws java.sql.SQLException
Throws:
java.sql.SQLException

execSQL

ResultSet execSQL(java.lang.String sql,
                  int maxRows,
                  Buffer packet,
                  java.lang.String catalog)
            throws java.sql.SQLException
Throws:
java.sql.SQLException

execSQL

ResultSet execSQL(java.lang.String sql,
                  int maxRows,
                  Buffer packet,
                  int resultSetType,
                  java.lang.String catalog)
            throws java.sql.SQLException
Throws:
java.sql.SQLException

execSQL

ResultSet execSQL(java.lang.String sql,
                  int maxRows,
                  Buffer packet,
                  int resultSetType,
                  boolean streamResults,
                  boolean queryIsSelectOnly,
                  java.lang.String catalog)
            throws java.sql.SQLException
Throws:
java.sql.SQLException

maxRowsChanged

void maxRowsChanged(Statement stmt)
Has the maxRows value changed?

Parameters:
stmt - DOCUMENT ME!

unsetMaxRows

void unsetMaxRows(Statement stmt)
            throws java.sql.SQLException
Called by statements on their .close() to let the connection know when it is safe to set the connection back to 'default' row limits.

Parameters:
stmt - the statement releasing it's max-rows requirement
Throws:
java.sql.SQLException - if a database error occurs issuing the statement that sets the limit default.

useAnsiQuotedIdentifiers

boolean useAnsiQuotedIdentifiers()

useHostsInPrivileges

boolean useHostsInPrivileges()

useMaxRows

boolean useMaxRows()
Has maxRows() been set?

Returns:
DOCUMENT ME!

useStreamLengthsInPrepStmts

boolean useStreamLengthsInPrepStmts()

getCharacterSetMetadata

protected java.lang.String getCharacterSetMetadata()
Returns:
Returns the characterSetMetadata.

getServerCharacterEncoding

protected java.lang.String getServerCharacterEncoding()
Returns the server's character set

Returns:
the server's character set.

getRollbackOnPooledClose

public boolean getRollbackOnPooledClose()
Returns:
Returns the rollbackOnPooledClose.

getUseOnlyServerErrorMessages

protected boolean getUseOnlyServerErrorMessages()
Returns:
Returns the useOnlyServerErrorMessages.

getTinyint1isBit

public boolean getTinyint1isBit()
Returns: