You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beehive.apache.org by Alexander Shopov <as...@contact.bg> on 2007/09/04 11:57:55 UTC

[SPAM] Transactions with JDBCcontrols (and in controllers)

Hi,
I would like to know whether there is a way to begin, rollback and 
commite transactions via JDBCcontrols and whether the behavior is same 
when the control is injected in a web controller.

For example:

JDBCControl
-----------------
public interface TestControl extends JdbcControl {

     @SQL(statement="{sql: statement}")
     public void execSQLStatement (String statement) throws SQLException;
}


The Controller uses the injected TestControl and executes:
1. CASE A
Several calls to TestControl.execSQLStatement in a single @Jpf.Action 
with BEGIN TRANSACTION, SAVEPOINT, COMMIT
Is the transaction held throughout the @Jpf.Action method
2. CASE B
Several calls to TestControl.execSQLStatement in a several @Jpf.Action 
with BEGIN TRANSACTION, SAVEPOINT, COMMIT
Is the transaction held throughout all the @Jpf.Action methods

Kind regards:
al_shopov

Re: [SPAM] Transactions with JDBCcontrols (and in controllers)

Posted by Jacob Danner <ja...@gmail.com>.
Hi Alexander,
If you are using weblogic you might find the following links useful.
What you are looking for should be possible using the controls
Transaction attribute.
Here is an edocs link explaining it in further detail
http://e-docs.bea.com/wlw/docs101/guide/controls/conControlTransactions.html
and here is a similar post on a newsgroup
http://forums.bea.com/thread.jspa?threadID=300002461

If not, you can use a custom control to 'wrap' the jdbc calls in a
UserTransaction
// some pseudo to help demonstrate
//in some CustomControl
@Control
TestControl jdbc;

public void execSomeSqlStatement()
  UserTransaction ut = //init this properly
  ut.begin();
  try{
    jdbc.execSQLStatement(statement);
    ut.commit();
  }catch(SomeException se){
    ut.rollback()
  }
}

Hope this helps,
-jacobd


On 9/4/07, Alexander Shopov <as...@contact.bg> wrote:
> Hi,
> I would like to know whether there is a way to begin, rollback and
> commite transactions via JDBCcontrols and whether the behavior is same
> when the control is injected in a web controller.
>
> For example:
>
> JDBCControl
> -----------------
> public interface TestControl extends JdbcControl {
>
>      @SQL(statement="{sql: statement}")
>      public void execSQLStatement (String statement) throws SQLException;
> }
>
>
> The Controller uses the injected TestControl and executes:
> 1. CASE A
> Several calls to TestControl.execSQLStatement in a single @Jpf.Action
> with BEGIN TRANSACTION, SAVEPOINT, COMMIT
> Is the transaction held throughout the @Jpf.Action method
> 2. CASE B
> Several calls to TestControl.execSQLStatement in a several @Jpf.Action
> with BEGIN TRANSACTION, SAVEPOINT, COMMIT
> Is the transaction held throughout all the @Jpf.Action methods
>
> Kind regards:
> al_shopov
>