You are creating a new UserTransaction when you commit. You need to use

one transaction(see my coments below)

 

  Tommy Wassgren <[EMAIL PROTECTED]> wrote:

I'm using a data-source (Oracle) from a stateless session bean.
The session bean uses bean managed transactions (User transactions).
Reading and writing data to the Oracle database works fine.

The only problem is that when the ejb-transaction gets rolled back the
database transaction does not roll back.

Simplified example:


// Get the connection
Context context = new InitialContext();
ds = (DataSource)context.lookup("jdbc/MyDSCore");
Connection conn = ds.getConnection();
conn.setAutoCinnit(false);


try
{
---------------->>    UserTransaction transaction = sessionContext.getUserTransaction().begin();

conn.createStatement(.....);
conn.executeUpdate();

// If a rollback occurs here the data still gets updated

...
---------------->>transaction.commit();
}
catch(Exception e)!
{
e.printStackTrace();
----------->>> transaction.rollback();
}


My data-sources.xml looks like this:


class="com.evermind.sql.DriverManagerDataSource"
name="MyDS"
connection-driver="oracle.jdbc.driver.OracleDriver"
location="jdbc/MyDSCore"
username="scott"
password="tiger"
url="jdbc:oracle:thin:@SERVER:PORT:SID"
/>


Does anyone have any idea of why the transactions are not working
properly???




Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger.

Reply via email to