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:
<i>
// Get the connection
Context context = new InitialContext();
ds = (DataSource)context.lookup("jdbc/MyDSCore");
Connection conn = ds.getConnection();
conn.setAutoCinnit(false);
try
{
sessionContext.getUserTransaction().begin();
conn.createStatement(.....);
conn.executeUpdate();
// If a rollback occurs here the data still gets updated
...
sessionContext.getUserTransaction().commit();
}
catch(Exception e)
{
e.printStackTrace();
sessionContext.getUserTransaction().rollback();
}
</i>
My <b>data-sources.xml</b> looks like this:
<i>
<data-source
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"
/>
</i>
Does anyone have any idea of why the transactions are not working
properly???