xmlBlaster 2.2.0 API

org.xmlBlaster.contrib.db
Interface I_DbPool

All Superinterfaces:
I_ContribPlugin
All Known Implementing Classes:
DbPool, DbWaitingPool

public interface I_DbPool
extends I_ContribPlugin

Interface to a JDBC pool implementation.

Author:
Marcel Ruff

Method Summary
 void erase(java.sql.Connection con)
          Destroy the JDBC connection
 I_Info getInfo()
           
 java.lang.String getUser()
           
 void init(I_Info info)
          Needs to be called after construction.
 void release(java.sql.Connection con)
          Return the JDBC connection to the pool.
 java.sql.Connection reserve()
          Access a JDBC connection.
 java.sql.Connection select(java.sql.Connection connection, java.lang.String command, boolean autoCommit, I_ResultCb cb)
          To have full control.
 java.sql.Connection select(java.sql.Connection connection, java.lang.String command, I_ResultCb cb)
          Convenience method to execute a SELECT SQL command.
 void select(java.lang.String command, I_ResultCb cb)
          Convenience method to execute a SELECT SQL command in auto commit mode.
 void shutdown()
          Close all open connections and destroy the pool.
 int update(java.sql.Connection conn, java.lang.String command)
           
 int update(java.lang.String command)
          Convenience method to execute a INSERT/UPDATE/CREATE or DROP SQL command in auto commit mode.
 
Methods inherited from interface org.xmlBlaster.contrib.I_ContribPlugin
getUsedPropertyKeys
 

Method Detail

init

void init(I_Info info)
Needs to be called after construction.

Specified by:
init in interface I_ContribPlugin
Parameters:
info - The configuration

getInfo

I_Info getInfo()

reserve

java.sql.Connection reserve()
                            throws java.lang.Exception
Access a JDBC connection.

Returns:
The JDBC connection
Throws:
java.lang.Exception

release

void release(java.sql.Connection con)
             throws java.lang.Exception
Return the JDBC connection to the pool.

Parameters:
con - The JDBC connection
Throws:
java.lang.Exception

getUser

java.lang.String getUser()
Returns:
the name of the user

erase

void erase(java.sql.Connection con)
           throws java.lang.Exception
Destroy the JDBC connection

Parameters:
con - The JDBC connection
Throws:
java.lang.Exception

update

int update(java.lang.String command)
           throws java.lang.Exception
Convenience method to execute a INSERT/UPDATE/CREATE or DROP SQL command in auto commit mode.

Parameters:
command - for example INSERT INTO TEST_POLL VALUES ('1', 'EDDI')
Returns:
Number of touched entries
Throws:
java.lang.Exception - Typically a SQLException

update

int update(java.sql.Connection conn,
           java.lang.String command)
           throws java.lang.Exception
Throws:
java.lang.Exception

select

void select(java.lang.String command,
            I_ResultCb cb)
            throws java.lang.Exception
Convenience method to execute a SELECT SQL command in auto commit mode.

Parameters:
command - for example SELECT * FROM TEST_POLL
cb - The callback handle for the retrieved ResultSet
Throws:
java.lang.Exception - Typically a SQLException

select

java.sql.Connection select(java.sql.Connection connection,
                           java.lang.String command,
                           I_ResultCb cb)
                           throws java.lang.Exception
Convenience method to execute a SELECT SQL command.

On first call pass connection with null and a valid connection with an open transaction is returned by this method. You can now call this method passing the connection multiple times in the same transaction. When you are done you need to close the connection and put it back into the pool.

Example:
      Connection conn = null;

      try {
         conn = this.dbPool.select(conn, "SELECT A FROM B", new I_ResultCb() {
            public void result(ResultSet rs) throws Exception {
               // Processing result set
            }
         });

         conn = this.dbPool.select(conn, "SELECT B FROM  C", new I_ResultCb() {
            public void result(ResultSet rs) throws Exception {
               // Processing result set
            }
         });
      }
      finally {
         if (conn != null) {
            conn.commit();
            this.dbPool.release(conn);
         }
      }
 

Parameters:
connection - If null a connection is created
command - for example SELECT * FROM TEST_POLL
cb - The callback handle for the retrieved ResultSet
Returns:
If not null you need to put the connection back to the pool yourself
Throws:
java.lang.Exception - Typically a SQLException

select

java.sql.Connection select(java.sql.Connection connection,
                           java.lang.String command,
                           boolean autoCommit,
                           I_ResultCb cb)
                           throws java.lang.Exception
To have full control.

Parameters:
connection - If null a connection is created
command - for example SELECT * FROM TEST_POLL
autoCommit - if true force auto commit and cleanup the connection, in this case we return null
cb - The callback handle for the retrieved ResultSet
Returns:
If not null you need to put the connection back to the pool yourself
Throws:
java.lang.Exception - Typically a SQLException

shutdown

void shutdown()
              throws java.lang.Exception
Close all open connections and destroy the pool. All resources are released.

Specified by:
shutdown in interface I_ContribPlugin
Throws:
java.lang.Exception
See Also:
I_Plugin

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.