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

Class com.imaginary.sql.msql.MsqlConnection

java.lang.Object
  |
  +--com.imaginary.sql.msql.MsqlConnection

public class MsqlConnection
extends java.lang.Object
implements java.sql.Connection
The MsqlConnection class is an implementation of the JDBC Connection interface that represents a database transaction. This class should never be directly instantiated by an application, but instead should be gotten by calling DriverManager.getConnection().
Last modified $Date: 1999/07/06 05:55:59 $

Version:
$Revision: 1.6 $
Author:
George Reese (borg@imaginary.com)
See Also:
getConnection

Field Summary
java.lang.String database
           
MsqlInputStream input
           
MsqlOutputStream output
           
java.lang.String url
           
java.lang.String user
           
int version
           
java.lang.String versionString
           
 
Method Summary
void clearWarnings()
          Since mSQL produces no warnings, this is a NO-OP
void close()
          Closes this database connection.
void commit()
          This is a NO-OP for mSQL. All statements are always auto-committed.
java.sql.Statement createStatement()
          This JDBC method creates an instance of MsqlStatement that is forward-only and read-only.
java.sql.Statement createStatement(int type, int concur)
          Creates a JDBC Statement whose result sets have the specified cursor type and concurrency model.
boolean getAutoCommit()
          This method always returns true since mSQL is always in auto-commit mode.
java.lang.String getCatalog()
          Provides the catalog name.
java.lang.String getEncoding()
           
java.sql.DatabaseMetaData getMetaData()
          Provides meta-data for the database connection.
int getTransactionIsolation()
           
java.util.Map getTypeMap()
           
java.lang.String getUser()
           
java.sql.SQLWarning getWarnings()
          mSQL does not have warnings.
boolean isClosed()
           
boolean isReadOnly()
          mSQL does not support read only connections, only read-only access rights.
java.lang.String nativeSQL(java.lang.String sql)
          This gives the driver an opportunity to turn JDBC compliant SQL into mSQL specific SQL. My feeling is why bother.
java.sql.CallableStatement prepareCall(java.lang.String unused)
          Callable statements are not supported by mSQL. This will therefore always throw an exception.
java.sql.CallableStatement prepareCall(java.lang.String unused, int type, int concur)
          Callable statements are not supported by mSQL. This will therefore always throw an exception.
java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          Constructs a PreparedStatement matching the specified statement.
java.sql.PreparedStatement prepareStatement(java.lang.String sql, int type, int concur)
          Creates a prepared statement with the specified type and concurrency for its result sets.
void rollback()
          This method always errors since you cannot rollback an mSQL transaction.
void setAutoCommit(boolean b)
          This method will thrown an exception if you try to turn auto-commit off since JDBC does not support transactional logic.
void setCatalog(java.lang.String db)
          Selects the database to be used by this connection.
void setReadOnly(boolean b)
          mSQL does not support read-only mode.
void setTransactionIsolation(int unused)
          This is not supported by mSQL, thus this is a NO-OP. The transaction isolation level is always set to Connection.
void setTypeMap(java.util.Map map)
          Sets the type map for this connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

database

protected java.lang.String database

input

protected MsqlInputStream input

output

protected MsqlOutputStream output

url

protected java.lang.String url

user

protected java.lang.String user

version

protected int version

versionString

protected java.lang.String versionString
Method Detail

clearWarnings

public void clearWarnings()
                  throws java.sql.SQLException
Since mSQL produces no warnings, this is a NO-OP
Specified by:
clearWarnings() in interface java.sql.Connection
Throws:
java.sql.SQLException - this is never thrown

close

public void close()
          throws java.sql.SQLException
Closes this database connection. It will also close any associated Statement instances.
Specified by:
close() in interface java.sql.Connection
Throws:
java.sql.SQLException - thrown if problems occur

commit

public void commit()
           throws java.sql.SQLException
This is a NO-OP for mSQL. All statements are always auto-committed.
Specified by:
commit() in interface java.sql.Connection
Throws:
java.sql.SQLException - this is never thrown

createStatement

public java.sql.Statement createStatement()
                                  throws java.sql.SQLException
This JDBC method creates an instance of MsqlStatement that is forward-only and read-only. Note that mSQL does not provide a way to interrupt executing statements, so it has to wait for any pending statements to finish before closing them.
Specified by:
createStatement() in interface java.sql.Connection
Returns:
a new MsqlStatement instance
Throws:
java.sql.SQLException - an error occurred in creating the Statement instance, likely raised by the constructor

createStatement

public java.sql.Statement createStatement(int type,
                                 int concur)
                                  throws java.sql.SQLException
Creates a JDBC Statement whose result sets have the specified cursor type and concurrency model.
Specified by:
createStatement(int, int) in interface java.sql.Connection
Parameters:
type - the result set type for the statement
concur - the result set concurrency
Returns:
a brand new Statement
Throws:
java.sql.SQLException - the Connection was unable to create a new Statement

getAutoCommit

public boolean getAutoCommit()
                     throws java.sql.SQLException
This method always returns true since mSQL is always in auto-commit mode.
Specified by:
getAutoCommit() in interface java.sql.Connection
Returns:
true--always
Throws:
java.sql.SQLException - never thrown

getCatalog

public java.lang.String getCatalog()
                           throws java.sql.SQLException
Provides the catalog name. For mSQL, this is the database to which you are connected.
Specified by:
getCatalog() in interface java.sql.Connection
Returns:
always null
Throws:
java.sql.SQLException - never thrown

getEncoding

public java.lang.String getEncoding()
Returns:
the encoding for the application

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                     throws java.sql.SQLException
Provides meta-data for the database connection.
Specified by:
getMetaData() in interface java.sql.Connection
Returns:
the mSQL implementation of DatabaseMetaData
Throws:
java.sql.SQLException - this is never thrown

getTransactionIsolation

public int getTransactionIsolation()
                           throws java.sql.SQLException
Description copied from interface:
 
Specified by:
getTransactionIsolation() in interface java.sql.Connection
Returns:
the transaction isolation, always Connection.TRANSACTION_NONE
Throws:
java.sql.SQLException - this is never thrown

getTypeMap

public java.util.Map getTypeMap()
                        throws java.sql.SQLException
Description copied from interface:
 
Specified by:
getTypeMap() in interface java.sql.Connection
Returns:
the type map associated with this connection
Throws:
java.sql.SQLException - this is never thrown

getUser

public java.lang.String getUser()
                        throws java.sql.SQLException
Returns:
the user name used for this Connection
Throws:
java.sql.SQLException - this is never thrown

getWarnings

public java.sql.SQLWarning getWarnings()
                               throws java.sql.SQLException
mSQL does not have warnings.
Specified by:
getWarnings() in interface java.sql.Connection
Returns:
always null
Throws:
java.sql.SQLException - this is never thrown

isClosed

public boolean isClosed()
Description copied from interface:
 
Specified by:
isClosed() in interface java.sql.Connection
Returns:
true if this Connection has been closed

isReadOnly

public boolean isReadOnly()
                  throws java.sql.SQLException
mSQL does not support read only connections, only read-only access rights.
Specified by:
isReadOnly() in interface java.sql.Connection
Returns:
false--always

nativeSQL

public java.lang.String nativeSQL(java.lang.String sql)
                          throws java.sql.SQLException
This gives the driver an opportunity to turn JDBC compliant SQL into mSQL specific SQL. My feeling is why bother.
Specified by:
nativeSQL(java.lang.String) in interface java.sql.Connection
Throws:
java.sql.SQLException - never thrown

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String unused)
                                      throws java.sql.SQLException
Callable statements are not supported by mSQL. This will therefore always throw an exception.
Specified by:
prepareCall(java.lang.String) in interface java.sql.Connection
Parameters:
unused - the name of the stored procedure
Returns:
nothing, it always throws an exception
Throws:
java.sql.SQLException - this will always be thrown

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String unused,
                                     int type,
                                     int concur)
                                      throws java.sql.SQLException
Callable statements are not supported by mSQL. This will therefore always throw an exception.
Specified by:
prepareCall(java.lang.String, int, int) in interface java.sql.Connection
Parameters:
unused - the name of the stored procedure
type - the type of the procs result sets
concur - the concurrency of the result sets
Returns:
nothing, it always throws an exception
Throws:
java.sql.SQLException - this will always be thrown

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                           throws java.sql.SQLException
Constructs a PreparedStatement matching the specified statement. Note that mSQL does not natively support prepared statements, so mSQL-JDBC prepared statement support is a bit faked. In other words, there is absolutely no performance benedit to using prepared statements with mSQL.
Specified by:
prepareStatement(java.lang.String) in interface java.sql.Connection
Parameters:
sql - the prepared statement
Returns:
a new PreparedStatement matching the specified SQL
Throws:
java.sql.SQLException - the Connection was unable to create a PreparedStatement for the specified SQL

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                          int type,
                                          int concur)
                                           throws java.sql.SQLException
Creates a prepared statement with the specified type and concurrency for its result sets.
Specified by:
prepareStatement(java.lang.String, int, int) in interface java.sql.Connection
Parameters:
sql - the SQL of the prepared statement
type - the type of the result sets for the prepared statements
concur - the concurrency of the result sets
Returns:
a new prepared statement
Throws:
java.sql.SQLException - the prepared statement could not be created

rollback

public void rollback()
             throws java.sql.SQLException
This method always errors since you cannot rollback an mSQL transaction.
Specified by:
rollback() in interface java.sql.Connection
Throws:
java.sql.SQLException - this will always get thrown by this method

setAutoCommit

public void setAutoCommit(boolean b)
                  throws java.sql.SQLException
This method will thrown an exception if you try to turn auto-commit off since JDBC does not support transactional logic.
Specified by:
setAutoCommit(boolean) in interface java.sql.Connection
Parameters:
b - should always be true
Throws:
java.sql.SQLException - thrown if the param is false

setCatalog

public void setCatalog(java.lang.String db)
               throws java.sql.SQLException
Selects the database to be used by this connection.
Specified by:
setCatalog(java.lang.String) in interface java.sql.Connection
Parameters:
db - the name of the mSQL database
Throws:
java.sql.SQLException - failed to set the new database

setReadOnly

public void setReadOnly(boolean b)
                throws java.sql.SQLException
mSQL does not support read-only mode.
Specified by:
setReadOnly(boolean) in interface java.sql.Connection
Parameters:
b - should only ever be false
Throws:
java.sql.SQLException - this is thrown if an attempt is made to put the driver in read-only mode

setTransactionIsolation

public void setTransactionIsolation(int unused)
                            throws java.sql.SQLException
This is not supported by mSQL, thus this is a NO-OP. The transaction isolation level is always set to Connection.TRANSACTION_NONE.
Specified by:
setTransactionIsolation(int) in interface java.sql.Connection
Parameters:
unused - the transaction isolation level
Throws:
java.sql.SQLException - this is never thrown
See Also:
TRANSACTION_NONE

setTypeMap

public void setTypeMap(java.util.Map map)
               throws java.sql.SQLException
Sets the type map for this connection.
Specified by:
setTypeMap(java.util.Map) in interface java.sql.Connection
Parameters:
map - the new type map
Throws:
java.sql.SQLException - this is never thrown

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