I hava done a test to use the MySQL XADataSource. For MySQL has no MYSQLXADataSourceFactory class, so I coded one to produce MysqlXADataSource. MysqlXADataSource is configured in tomcat 5.5 server.xml. I can get the MysqlXADataSource instance xaDs by which I can get XAConnection and XAResource. I also configured a UserTransaction which was produced by org.objectweb.jotm.UserTransactionFactory. The following is the action's code in a test web application. This action runs correctly the first time, but in the second time, it runs very slow, then reports "Lock wait timeout exceeded; try restarting transaction" error.
The first question is that it seems the action did not update the table testdata's data. Did the UserTransaction ut have some error not participate in the database transaction? The second question is that I have searched this error, but don't know how to solve it. Please give me some tips. Must I not use MySQL's XA in Kandula ? Thanks. The java code (JOTM example): ======================================================== UserTransaction ut = null; try{ Context ctx = new InitialContext(); MysqlXADataSource xaDs = (MysqlXADataSource)ctx.lookup("java:comp/env/jdbc/myXADB"); ut = (UserTransaction)ctx.lookup("java:comp/env/UserTransaction"); XAConnection xCon = xaDs.getXAConnection(); java.sql.Connection conn = xCon.getConnection(); System.out.println("<<< beginning the transaction >>> xa con = " + conn); ut.begin(); // JDBC statements Statement stmt = conn.createStatement(); ResultSet rst = stmt.executeQuery("select id, foo from testdata"); if(rst.next()) { foo=rst.getInt(2); } System.out.println("foo = "+ foo +" (before completion)"); String sql = "update testdata set foo=" + (++foo) + " where id=1"; stmt.executeUpdate(sql);// <=== The program will wait here, and then report the error message ! ut.commit(); System.out.println("<<< committing the transaction >>>"); conn.close(); System.out.println("<<< done >>>"); }catch(Exception e) { System.out.print("DBTest >> "); e.printStackTrace(); System.out.println("<<< rolling back the transaction >>>"); try { ut.rollback(); System.out.println("rollback ok."); }catch(Exception e1){ System.out.println("rollback Error " + e1); } System.out.println("rollback end"); } } ======================================================== The error message: ======================================================== ==> xaDataSource = [EMAIL PROTECTED] <== <<< beginning the transaction >>> xa con = [EMAIL PROTECTED] foo = 29 (before completion) <<< committing the transaction >>> <<< done >>> <<< beginning the transaction >>> xa con = [EMAIL PROTECTED] foo = 29 (before completion) - set rollback only (tx=bb14:38:0:01777d30dfc9556034...986c02:) DBTest >> java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2822) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1536) at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1159) at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:684) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1184) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1101) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1086) at com.mysql.jdbc.jdbc2.optional.PreparedStatementWrapper.executeUpdate(PreparedStatementWrapper.java:840) at foo.XADBTest.init(XADBTest.java:92) at org.apache.jsp.testJotm_jsp._jspService(org.apache.jsp.testJotm_jsp:55) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) <<< rolling back the transaction >>> rollback ok. rollback end Wang Jun ___________________________________________________________ 情人节,用雅虎邮箱送玫瑰! --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]