ws-kandula-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dasarath Weeratunge <dweer...@purdue.edu>
Subject Fwd: Re: MySQL's XA problem
Date Sun, 12 Feb 2006 19:14:05 GMT
keep on forgetting to send replies to the list...

----- Forwarded message from Dasarath Weeratunge <dweeratu@purdue.edu> -----
    Date: Sun, 12 Feb 2006 14:11:35 -0500
    From: Dasarath Weeratunge <dweeratu@purdue.edu>
Reply-To: Dasarath Weeratunge <dweeratu@purdue.edu>
 Subject: Re: MySQL's XA problem
      To: Jack Wang <pipashu@yahoo.com>

Quoting Jack Wang <pipashu@yahoo.com>:
	
> 	
> 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");

How did u obtain this UserTransaction Object? It should come from the Geronimo 
TM object instantiated by Bridge.

> 
>     XAConnection xCon = xaDs.getXAConnection();

I don't see u enlisting this XAResource in your local tx object...

>     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 >>>");


Here we go once again. Please don't commit the tx in your code. The tx will be 
started and commited when you terminate your distributed (ws-at) tx using wa-at 
Completion protocol. If you want to rollback your tx, you may do so however. 
Even then it is better to mark the tx as "RollbackOnly".

I will give u some steps later on.

--dasarath

> 
>     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 = com.mysql.jdbc.jdbc2.optional.MysqlXADataSource@e2fbeb
> <==
> <<< beginning the transaction >>> xa con =
> com.mysql.jdbc.jdbc2.optional.ConnectionWrapper@170984c
> foo = 29 (before completion)
> <<< committing the transaction >>>
> <<< done >>>
> <<< beginning the transaction >>> xa con =
> com.mysql.jdbc.jdbc2.optional.ConnectionWrapper@4d5575
> 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.processConne
ction(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: kandula-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: kandula-dev-help@ws.apache.org
> 
> 



----- End forwarded message -----




---------------------------------------------------------------------
To unsubscribe, e-mail: kandula-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: kandula-dev-help@ws.apache.org


Mime
View raw message