Hi John ,
> There may however be a portability issue. Some appservers may
> require you to
> use XA caonnections within a JTA transaction. In that case,
> you will have to
> use an XA datasource (or XA connection pool, depending of
> your appserver
> vendor) within the JTA transaction and a none-XA datasource
> for the read
> operation, which would break your code.
>
This is exactly my concern. Im using weblogic server which got XA-datasource
and transactions work only with Connections taken from XA-Datasource.
My code will work if i take an XA connection after the transaction starts. My
concern is that i dont want to keep two connections with the same thread.
Im including my original question again
> // please ignore the syntax
>
> Connection conn = null;
> PreparedStatement pstmt = null
> ResultSet rs = null;
>
> try {
>
> // I may need to move the prepareStatement and
> getConnection call inside the
> // while
> loop
> conn = getConnection();
> pstmt = conn.prepareStatement(query);
>
> while(loopCondition){
>
> rs = pstmt.executeQuery();
> while(rs.next()){
>
> // do something
> dataObject.add(rs.getXXX(1));
>
> } // end rs loop
>
> // I need to get a new connection ( inside the transaction ) for
> transaction to work
> cleanUpConnection() // so i clean up the previous connections and
> statement
> //transaction begin
> // LABEL 1
> conn = getConnection();
> anotherObject.save(dataObject, conn)
> cleanUpConnection();
> // transation commit
>
> } // end loopCondition
>
> }finally{
> cleanUpConnection();
> }
>
>
> At LABEL 1 I need to get a new connection. Since I don't want the same thread
> to keep more than one connection, I need to close the previous connection
> object. When closing the connection, I also need to close the result set and
> the prepared statement associated with that connection.
>
> This will force me to move the getConnection() and prepareStatement() call to
> inside the while loop. So for each iteration im preparing the statement.
>
> How to handle this condition. I don't want my select and save in the same
> transaction. I don't want the same thread to hold two transactions.
>
> Will the application server ensure that I get the same PreparedStatement in
> each iteration. I remember reading that it does. I'm using UserTransaction
> object to manage the transaction.
>
> Is there any other way I can do this ?.
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".