Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class org.gjt.mm.mysql.Connection

java.lang.Object
  |
  +--org.gjt.mm.mysql.Connection

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

Constructor Summary
Connection(java.lang.String Host, int port, java.util.Properties Info, java.lang.String Database, java.lang.String Url, Driver D)
          Connect to a MySQL Server.
 
Method Summary
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.
java.sql.Statement createStatement()
          SQL statements without parameters are normally executed using Statement objects.
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.
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.
int getTransactionIsolation()
          Get this Connection's current transaction isolation mode.
java.sql.SQLWarning getWarnings()
          The first warning reported by calls on this Connection is returned.
boolean isClosed()
          Tests to see if a Connection is closed
boolean isReadOnly()
          Tests to see if the connection is in Read Only Mode.
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.
java.sql.CallableStatement prepareCall(java.lang.String sql)
          A SQL stored procedure call statement is handled by creating a CallableStatement for it.
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.
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 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 setReadOnly(boolean readOnly)
          You can put a connection in read-only mode as a hunt to enable database optimizations Note: setReadOnly cannot be called while in the middle of a transaction
void setTransactionIsolation(int level)
          You can call this method to try to change the transaction isolation level using one of the TRANSACTION_* values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Constructor Detail

Connection

public Connection(java.lang.String Host,
                  int port,
                  java.util.Properties Info,
                  java.lang.String Database,
                  java.lang.String Url,
                  Driver D)
           throws java.sql.SQLException
Connect to a MySQL Server.

Important Notice
Although this will connect to the database, user code should open the connection via the DriverManager.getConnection() methods only.
This should only be called from the postgresql.Driver class.

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

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

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. MySQL does not support 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 SQLExceptions
Specified by:
prepareStatement(java.lang.String) 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.

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                      throws java.sql.SQLException
A SQL stored procedure call statement is handled by creating a CallableStatement for it. The CallableStatement provides methods for setting up its IN and OUT parameters and methods for executing it. Note: This method is optimised for handling stored procedure call statements. Some drivers may send the call statement to the database when the prepareCall is done; others may wait until the CallableStatement is executed. This has no direct effect on users; however, it does affect which method throws certain SQLExceptions
Specified by:
prepareCall(java.lang.String) in interface java.sql.Connection
Parameters:
sql - a SQL statement that may contain one or more '?' parameter placeholders. Typically this statement is a JDBC function call escape string.
Returns:
a new CallableStatement object containing the pre-compiled SQL statement
Throws:
java.sql.SQLException - if a database access error occurs

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(java.lang.String) 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

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(boolean) in interface java.sql.Connection
Parameters:
autoCommit - - true enables auto-commit; false disables it
Throws:
java.sql.SQLException - if a database access error occurs

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

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. (If autoCommit == true, then we just return anyhow)

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

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

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.

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

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

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

isClosed

public boolean isClosed()
                throws java.sql.SQLException
Tests to see if a Connection is closed
Specified by:
isClosed() in interface java.sql.Connection
Returns:
the status of the connection
Throws:
java.sql.SQLException - (why?)

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

setReadOnly

public void setReadOnly(boolean readOnly)
                throws java.sql.SQLException
You can put a connection in read-only mode as a hunt to enable database optimizations Note: setReadOnly cannot be called while in the middle of a transaction
Specified by:
setReadOnly(boolean) 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

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 does not support Catalogs

Specified by:
setCatalog(java.lang.String) in interface java.sql.Connection
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 does not support Catalogs

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

setTransactionIsolation

public void setTransactionIsolation(int level)
                            throws java.sql.SQLException
You can call this method to try to change the transaction isolation level using one of the TRANSACTION_* values. Note: setTransactionIsolation cannot be called while in the middle of a transaction
Specified by:
setTransactionIsolation(int) in interface java.sql.Connection
Parameters:
level - one of the TRANSACTION_* isolation values with the exception of TRANSACTION_NONE; some databases may not support other values
Throws:
java.sql.SQLException - if a database access error occurs
See Also:
supportsTransactionIsolationLevel

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

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 SQLWarning
Specified by:
getWarnings() in interface java.sql.Connection
Returns:
the first SQLWarning or null
Throws:
java.sql.SQLException - if a database access error occurs

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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD