Hi everyone, I'm heavily using JMX based services inside a JBoss 4.2.3 application server (.sar project). But I am not able to manage a JDBC transaction through UserTransaction. The statements get executed before I commit the transaction and when I rollback the changes are not undone. I use a local-tx-datasource MySQL JDBC datasource
| <local-tx-datasource> | <jndi-name>myDs</jndi-name> | <connection-url>jdbc:mysql://myserver:3306/opensips</connection-url> | <driver-class>com.mysql.jdbc.Driver</driver-class> | <user-name>myuser</user-name> | <password>mypwd</password> | <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name> | | <metadata> | <type-mapping>mySQL</type-mapping> | </metadata> | </local-tx-datasource> | and I think I'm correctly using the JTA API | Connection conn = null; | UserTransaction tx=null; | try { | DataSource ds=(DataSource) this.getResource(this.opensipsDs); | tx=(UserTransaction) this.getResource("UserTransaction"); | tx.begin(); | conn=ds.getConnection(); | String activateSql="insert into grp (username, grp) values (?, 'active')"; | String deactivateSql="delete from grp where username=?"; | | PreparedStatement ps; | Set<String> lineas=estados.keySet(); | for(String linea:lineas) { | if(estados.get(linea)) { | //activar | ps=conn.prepareStatement(activateSql); | } else { | //desactivar | ps=conn.prepareStatement(deactivateSql); | } | | ps.setString(1, linea); | ps.executeUpdate(); | } | | tx.commit(); | } catch (Exception e) { | this.log.error("error al realizar modificacion en opensips", e); | if(tx!=null) | try { | tx.rollback(); | } catch (Exception ex) { | this.log.info("no se pudo realizar rollback"); | } | } finally { | try { | if(conn!=null&&!conn.isClosed()) { | conn.close(); | } | } catch (SQLException e) { | this.log.debug("la coneccion ya esta cerrada"); | } | } | Can I use the JTA API inside an MBean? Thank for you help View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4233444#4233444 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4233444 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user