Quoting Jack Wang <[EMAIL PROTECTED]>:
> Bank1.creditImpl(acc, dollars) {
> // Get tx
> org.apache.geronimo.transaction.manager.TransactionManagerImpl tmImpl =
> new org.apache.geronimo.transaction.manager.TransactionManagerImpl();
don't create another instance of the transaction manager. This will not work.
Use the instance created by Kandula.
> javax.transaction.Transaction tx = tmImpl.getTransaction();
>
> // Get ut and xARes
> Context ctx = new InitialContext();
> UserTransaction ut =
> (UserTransaction)ctx.lookup("java:comp/env/UserTransaction");
> XADataSource xaDs = (XADataSource)ctx.lookup("java:comp/env/jdbc/myXADB");
> <-- Oops, NULL value
> !!
> XAConnection xAConn = xaDs.getXAConnection();
> XAResource xARes = xAConn.getXAResource();
>
> // Enlist xARes
> tx.enlistResource(xARes);
>
> // Begin ut
> ut.begin();
>
> // Operate db
> java.sql.Connection conn = xAConn.getConnection();
> Statement stmt = conn.createStatement();
> PreparedStatement pstmt = conn.prepareStatement("update ...");
>
> // Commit ut
> ut.commit();
As I've told you BEFORE, you should neither begin nor commit the tx. Tx will
be created automatically by the runtime when the method is called. You just have
to obtain a reference to it by some means and then enlist your resources. (Even
this should be done by the container). You don't seem to understand the concept
of distributed transaction. I suggest that you read a little bit about how
ejb's handle transactions. Especially the section on Bean managed tx and
container managed tx in the EJB spec.
> // Return
> return "";
> }
> --------------------------------------
>
> Question 1)
> Is the code right ?
>
> Question 2)
> I use JDK 1.5, Tomcat 5.5, MySQL: 5.0.18-win32,
if u are using jdk 1.5, please keep in mind that Kandula has ONLY been tested
on jdk 1.4.2
--dasarath
> mysql-connector-java-5.0.0-beta. I have
> configured the XADataSource in tomcat's server.xml, but I only get a null
> xaDs, Oops !! So there
> is no xARes yet. I have put this question in mysql mail list. This is the
> XADataSource
> configuration in server.xml:
>
> --------------------------------------
> <Resource name="jdbc/myXADB" auth="Container"
> type="javax.sql.XADataSource"
> factory="com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory"
> driverClassName="com.mysql.jdbc.Driver"
> user="root"
> password="password"
>
> url="jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=gbk"
> />
> --------------------------------------
>
> I still tried to test kandula. Please help. Thanks.
>
>
>
> Wang Jun
>
>
>
>
>
>
> ___________________________________________________________
> ÑÅ»¢1GÃâ·ÑÓÊÏä°Ù·Ö°Ù·ÀÀ¬»øÐÅ
> http://cn.mail.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]