www.element4solution.com

e4s.db
Class E4DBConnectionTransactional

java.lang.Object
  extended by e4s.util.E4Object
      extended by e4s.db.E4DBConnectionDefault
          extended by e4s.db.E4DBConnectionTransactional
All Implemented Interfaces:
E4DBConnection_Intf

public class E4DBConnectionTransactional
extends E4DBConnectionDefault
implements E4DBConnection_Intf

This is the main class that connects the application with the database, there is no single statement transaction defined, so you must take care of transactions using commit/rollback functionality. By default, when the connection is closed a commit() will be performed. Each object of this class is a new connection to the database. Hold this objects for a short period only, avoid to store them as session objects over several user requests. As with each object a connection is created on the JDBC driver, depending on the product and license of your database or JDBC driver you might run out of connections if there are some limitations!

Example_DB_Transaction.java

Since:
JDK 1.4
See Also:
E4DBSettings, E4DBConnectionDefault

Field Summary
 
Fields inherited from class e4s.db.E4DBConnectionDefault
_DB_TYPE_DB2, _DB_TYPE_MS_ACCESS, _DB_TYPE_MY_SQL, _DB_TYPE_OTHER, _DB_TYPE_SQL_SERVER, JDBCDRIVER_MS, JDBCDRIVER_OPTA, JDBCDRIVER_SUN, m_Connection, m_Connection_pooled, m_logging_checked, ms_aep_connection, ms_cached_connections, ms_connection_counter, ms_connection_counter_max, ms_JDBC_CONNECTION, ms_JDBC_DATABASE_TYPE, ms_JDBC_DRIVER
 
Fields inherited from class e4s.util.E4Object
CRLF, E4S_CORE_SYSTEM_LANGUAGE, NBSP, NULLSTR, URL_ENCODING_CHARSET
 
Constructor Summary
E4DBConnectionTransactional(java.sql.Connection con, int dbtype)
           
E4DBConnectionTransactional(java.lang.String driver_name, java.lang.String connection_name, int dbtype)
           
E4DBConnectionTransactional(java.lang.String driver_name, java.lang.String connection_name, java.lang.String userid, java.lang.String password, int dbtype)
           
 
Method Summary
static java.lang.String _getSVNVersionString()
          Get version info string from subversion.
 void close()
          Close the connection.
 void commit()
          Commit the current transaction - only when not running in SST mode (getAutoCommit()).
 void finalize()
           
 boolean getAutoCommit()
          Get the JDBC auto commit state (SST mode).
 java.lang.String getID()
           
static E4DBConnection_Intf getInstance()
           
static E4DBConnectionTransactional getTransactionalConnection()
           
 void rollback()
          Rollback the current transaction - only when not running in SST mode (getAutoCommit()).
 void setAutoCommit(boolean autocommit)
          Set the JDBC auto commit state (SST mode).
 
Methods inherited from class e4s.db.E4DBConnectionDefault
connectionIsPooled, getCatalog, getConnection, getConnectionCache, getConnectionCounter, getCreated, getDatabaseMetaData, getDatabaseType, getDefaultConnection, getIndexes, getJdbcConnection, getJdbcDriver, getStatement, getTables, getViews, init, initLogging, initMONITOR, initPool, initShared, istabledefined, resetConnectionCache, setAEP, setConnection, setConnection, setDatabaseType, setJdbcConnection, setJdbcDatabaseType, setJdbcDriver, toString
 
Methods inherited from class e4s.util.E4Object
Calendar, CName, CName, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelSys, E4LabelSys, e4sCopyright, e4sVersion, encode, encode, encode, encodeHtml, encodeHtml, encodeHtml, encodeURL, encodeURL, encodeURL, getLINE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTraceMemory, HtmlEncode, HtmlEncode, HtmlEncode, isdecimal, isdigit, isnotok, isnotok, isnumeric, isok, isok, isok, isok, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingStack, mkdirs, null2nbsp, null2nbsp, null2nbsp, ok, ok, ok, ok, outPrintln, setLogFile4Trace, setTraceMemory, STACKTRACE, toDebug, toDouble, toFloat, toFloat, TRACE_CALLS, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, wait
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface e4s.db.E4DBConnection_Intf
connectionIsPooled, getCatalog, getDatabaseMetaData, getDatabaseType, getIndexes, getStatement, getTables, istabledefined
 

Constructor Detail

E4DBConnectionTransactional

public E4DBConnectionTransactional(java.sql.Connection con,
                                   int dbtype)

E4DBConnectionTransactional

public E4DBConnectionTransactional(java.lang.String driver_name,
                                   java.lang.String connection_name,
                                   int dbtype)
                            throws E4DBException
Throws:
E4DBException

E4DBConnectionTransactional

public E4DBConnectionTransactional(java.lang.String driver_name,
                                   java.lang.String connection_name,
                                   java.lang.String userid,
                                   java.lang.String password,
                                   int dbtype)
                            throws E4DBException
Throws:
E4DBException
Method Detail

getInstance

public static E4DBConnection_Intf getInstance()
                                       throws E4DBException
Throws:
E4DBException

getTransactionalConnection

public static E4DBConnectionTransactional getTransactionalConnection()
                                                              throws E4DBException
Throws:
E4DBException

commit

public void commit()
            throws E4DBException
Commit the current transaction - only when not running in SST mode (getAutoCommit()). Refer to your JDBC documentation about this functionality.

Throws:
E4DBException
See Also:
rollback()

rollback

public void rollback()
              throws E4DBException
Rollback the current transaction - only when not running in SST mode (getAutoCommit()). Refer to your JDBC documentation about this functionality.

Throws:
E4DBException
See Also:
commit()

setAutoCommit

public void setAutoCommit(boolean autocommit)
                   throws E4DBException
Set the JDBC auto commit state (SST mode). Refer to your JDBC documentation about this functionality.

Parameters:
autocommit - true - this connection runs in auto commit mode, a commit() is not necessary and a rollback() will take no effect. false - You must take care of transactions using commit() or rollback().
Throws:
E4DBException
See Also:
getAutoCommit()

getAutoCommit

public boolean getAutoCommit()
                      throws E4DBException
Get the JDBC auto commit state (SST mode). Refer to your JDBC documentation about this functionality.

Returns:
true: this connection runs in auto commit mode, a commit() is not necessary and a rollback() will take no effect. false: You must take care of transactions using commit() or rollback().
Throws:
E4DBException
See Also:
#setAutoCommit()

close

public void close()
           throws E4DBException
Close the connection. This function is explicit delayed for 10ms to give some JDBC drivers a chance for clean-up tasks.

Specified by:
close in interface E4DBConnection_Intf
Overrides:
close in class E4DBConnectionDefault
Throws:
E4DBException

finalize

public void finalize()
Overrides:
finalize in class E4DBConnectionDefault

getID

public java.lang.String getID()
Specified by:
getID in interface E4DBConnection_Intf
Overrides:
getID in class E4DBConnectionDefault

_getSVNVersionString

public static java.lang.String _getSVNVersionString()
Get version info string from subversion.

Returns:
the version info string.
See Also:
E4Util.getRevisionCodeFromSVN(Class)

www.element4solution.com