org.mmbase.module.database
Class MultiConnection

java.lang.Object
  |
  +--org.mmbase.module.database.MultiConnection
All Implemented Interfaces:
java.sql.Connection

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

MultiConnection is a replacement class for Connection it provides you a multiplexed and reuseable connections from the connection pool


Field Summary
static int CON_BUSY
           
static int CON_FAILED
           
static int CON_FINISHED
           
static int CON_UNUSED
           
 int state
           
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Method Summary
 boolean checkSQLError(java.lang.Exception e)
           
 void claim()
           
 void clearWarnings()
          clear Warnings
 void close()
          Close connections
 void commit()
          Perform commit
 java.sql.Statement createStatement()
          createStatement returns an SQL Statement object
 java.sql.Statement createStatement(int i, int y)
          createStatement returns an SQL Statement object
 void delLastSQL()
          i changed this jun 2001, since i didn't understand the logic.
 boolean getAutoCommit()
          get AutoCommit mode
 java.lang.String getCatalog()
          The "catalog" name
 java.lang.String getLastSQL()
           
 java.sql.DatabaseMetaData getMetaData()
          Advanced features: You can obtain a DatabaseMetaData object to get information about the target database.
 int getStartTime()
           
 java.lang.String getStateString()
           
 int getTransactionIsolation()
           
 java.util.Map getTypeMap()
           
 int getUsage()
           
 java.sql.SQLWarning getWarnings()
          getWarnings will return any warning information related to the current connection.
 boolean isClosed()
          isClosed returns true if the connection is closed, which can occur either due to an explicit call on "close" or due to some fatal error on the connection.
 boolean isReadOnly()
          Is this database readonly ?
 java.lang.String nativeSQL(java.lang.String query)
           
 java.sql.CallableStatement prepareCall(java.lang.String sql)
           
 java.sql.CallableStatement prepareCall(java.lang.String sql, int i, int y)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          prepareStatement creates a pre-compiled SQL PreparedStatement object.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int i, int y)
          prepareStatement creates a pre-compiled SQL PreparedStatement object.
 void realclose()
          Close connections
 void release()
           
 void rollback()
          Perform rollback
 void setAutoCommit(boolean enableAutoCommit)
          If "autoCommit" is true, then all subsequent SQL statements will be executed and committed as individual transactions.
 void setCatalog(java.lang.String catalog)
          The "catalog" selects a sub-space of the target database.
 void setLastSQL(java.lang.String sql)
           
 void setReadOnly(boolean readOnly)
          You can put a connection in read-only mode as a hint to enable database optimizations.
 void setTransactionIsolation(int level)
          You can call the following method to try to change the transaction isolation level on a newly opened connection, using one of the TRANSACTION_* values.
 void setTypeMap(java.util.Map mp)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

state

public int state

CON_UNUSED

public static final int CON_UNUSED

CON_BUSY

public static final int CON_BUSY

CON_FINISHED

public static final int CON_FINISHED

CON_FAILED

public static final int CON_FAILED
Method Detail

getStateString

public java.lang.String getStateString()

setLastSQL

public void setLastSQL(java.lang.String sql)

delLastSQL

public void delLastSQL()
i changed this jun 2001, since i didn't understand the logic. I changed it to keep track of a state daniel.

getLastSQL

public java.lang.String getLastSQL()

createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException
createStatement returns an SQL Statement object
Specified by:
createStatement in interface java.sql.Connection

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
prepareStatement creates a pre-compiled SQL PreparedStatement object.
Specified by:
prepareStatement in interface java.sql.Connection

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
Specified by:
prepareCall in interface java.sql.Connection

nativeSQL

public java.lang.String nativeSQL(java.lang.String query)
                           throws java.sql.SQLException
Specified by:
nativeSQL in interface java.sql.Connection

setAutoCommit

public void setAutoCommit(boolean enableAutoCommit)
                   throws java.sql.SQLException
If "autoCommit" is true, then all subsequent SQL statements will be executed and committed as individual transactions. Otherwise (if "autoCommit" is false) then subsequent SQL statements will all be part of the same transaction , which must be explicitly committed with either a "commit" or "rollback" call. By default new connections are initialized with autoCommit "true".
Specified by:
setAutoCommit in interface java.sql.Connection

getAutoCommit

public boolean getAutoCommit()
                      throws java.sql.SQLException
get AutoCommit mode
Specified by:
getAutoCommit in interface java.sql.Connection

commit

public void commit()
            throws java.sql.SQLException
Perform commit
Specified by:
commit in interface java.sql.Connection

rollback

public void rollback()
              throws java.sql.SQLException
Perform rollback
Specified by:
rollback in interface java.sql.Connection

close

public void close()
           throws java.sql.SQLException
Close connections
Specified by:
close in interface java.sql.Connection

realclose

public void realclose()
               throws java.sql.SQLException
Close connections

isClosed

public boolean isClosed()
                 throws java.sql.SQLException
isClosed returns true if the connection is closed, which can occur either due to an explicit call on "close" or due to some fatal error on the connection.
Specified by:
isClosed in interface java.sql.Connection

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws java.sql.SQLException
Advanced features: You can obtain a DatabaseMetaData object to get information about the target database.
Specified by:
getMetaData in interface java.sql.Connection

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 that setReadOnly cannot be called while in the middle of a transaction.
Specified by:
setReadOnly in interface java.sql.Connection

isReadOnly

public boolean isReadOnly()
                   throws java.sql.SQLException
Is this database readonly ?
Specified by:
isReadOnly in interface java.sql.Connection

setCatalog

public void setCatalog(java.lang.String catalog)
                throws java.sql.SQLException
The "catalog" selects a sub-space of the target database.
Specified by:
setCatalog in interface java.sql.Connection

getCatalog

public java.lang.String getCatalog()
                            throws java.sql.SQLException
The "catalog" name
Specified by:
getCatalog in interface java.sql.Connection

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws java.sql.SQLException
You can call the following method to try to change the transaction isolation level on a newly opened connection, using one of the TRANSACTION_* values. Use the DatabaseMetaData class to find what isolation levels are supported by the current database. Note that setTransactionIsolation cannot be called while in the middle of a transaction.
Specified by:
setTransactionIsolation in interface java.sql.Connection

getTransactionIsolation

public int getTransactionIsolation()
                            throws java.sql.SQLException
Specified by:
getTransactionIsolation in interface java.sql.Connection

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
getWarnings will return any warning information related to the current connection. Note that SQLWarning may be a chain.
Specified by:
getWarnings in interface java.sql.Connection

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
clear Warnings
Specified by:
clearWarnings in interface java.sql.Connection

checkSQLError

public boolean checkSQLError(java.lang.Exception e)

claim

public void claim()

release

public void release()

getUsage

public int getUsage()

getStartTime

public int getStartTime()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int i,
                                              int y)
                                       throws java.sql.SQLException
Specified by:
prepareCall in interface java.sql.Connection

setTypeMap

public void setTypeMap(java.util.Map mp)
                throws java.sql.SQLException
Specified by:
setTypeMap in interface java.sql.Connection

getTypeMap

public java.util.Map getTypeMap()
                         throws java.sql.SQLException
Specified by:
getTypeMap in interface java.sql.Connection

createStatement

public java.sql.Statement createStatement(int i,
                                          int y)
                                   throws java.sql.SQLException
createStatement returns an SQL Statement object
Specified by:
createStatement in interface java.sql.Connection

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int i,
                                                   int y)
                                            throws java.sql.SQLException
prepareStatement creates a pre-compiled SQL PreparedStatement object.
Specified by:
prepareStatement in interface java.sql.Connection


MMBase 2001