You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Randy Layman <ra...@aswethink.com> on 2002/02/01 18:55:33 UTC

RE: Tyrex transaction in Tomcat

	First, this is a database problem and you should be asking on one of
the Oracle or Tyrex forumns.

	Second, you are calling statement.close before connection.rollback.
Try switching the calls and you should see your rollback occur.

	Randy


> -----Original Message-----
> From: Karambir Singh [mailto:ksingh@etouch.net]
> Sent: Friday, February 01, 2002 1:26 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Tyrex transaction in Tomcat
> 
> 
> I'm using oracle 8.1.6, Tomcat 4.0.1 and tyrex-0.9.7.0.jar.
> 
> In newtest.jsp when I try ut.rollback(), it does not 
> rollback. The data is
> committed instead.
> 
> What could be the problem. Anybody has working code using 
> Tyrex Transaction
> framework in Tomcat. Or anybody has a document on how to 
> integrate Tomcat4.0
> with Tyrex.
> 
> 
> 
> SERVER.XML
> ----------
> 	<ResourceParams name="jdbc/eTaskPool">
>             
> <parameter><name>user</name><value>arch</value></parameter>
>             
> <parameter><name>password</name><value>arch</value></parameter>
>             <parameter><name>driverClassName</name>
>               
> <value>oracle.jdbc.driver.OracleDriver</value></parameter>
>             <parameter><name>driverName</name>
>               
> <value>jdbc:oracle:thin:@tiger:1521:etouch</value></parameter>
>       </ResourceParams>
> 
> newtest.jsp
> -----------
> 
> <%@ page import="emp, javax.sql.*, java.sql.*, javax.naming.*,
> javax.transaction.*, tyrex.tm.*" %>
> 
> <%
> 	out.println("<p>Tomcat-Tyrex Integration Test");
> 	try
> 	{
> 		InitialContext  ctx;
> 		UserTransaction ut;
> 		DataSource      ds;
> 		Connection      conn;
> 		Statement       st;
> 		ResultSet       rs;
> 
> 		ctx = new InitialContext();
> 		Context envCtx = (Context) ctx.lookup( "java:/comp/");
> 		ut = (UserTransaction) envCtx.lookup( 
> "UserTransaction" );
> 		ds = (DataSource) ctx.lookup( 
> "java:/comp/env/jdbc/eTaskPool" );
> 		conn = ds.getConnection();
> 		conn.setAutoCommit(false);
> 
> 		ut.begin();
> 
> 		st = conn.createStatement();
> 		rs = st.executeQuery( "SELECT EMPNO FROM EMP 
> WHERE EMPNO=8" );
> 		if ( rs.next() )
> 		{
> 			out.println( "<p>Current value: " + 
> rs.getString( 1 ) );
> 		}
> 		else
> 		{
> 			out.println( "<p>Current value: null" );
> 			st.executeUpdate( "INSERT into EMP values (8)");
> 		}
> 		rs.close();
> 		st.close();
> 		ut.rollback();
> 
> 		conn.close();
> 
> 		return;
> 	}
> 	catch ( Throwable except )
> 	{
> 		out.println( "<pre>except" );
> 		except.printStackTrace();
> 		out.println( "</pre>" );
> 	}
> %>
> 
> 
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
> 

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


RE: Tyrex transaction in Tomcat

Posted by Karambir Singh <ks...@etouch.net>.
Hi Randy,

I'm not calling connection.rollback. I am calling transaction.rollback(). I
think problem is that there is no link between transaction and datasource.
And on Tyrex forum they havn't answered a single question after October
2001.

Karambir

-----Original Message-----
From: Randy Layman [mailto:randy.layman@aswethink.com]
Sent: Friday, February 01, 2002 9:56 AM
To: 'Tomcat Users List'
Subject: RE: Tyrex transaction in Tomcat



	First, this is a database problem and you should be asking on one of
the Oracle or Tyrex forumns.

	Second, you are calling statement.close before connection.rollback.
Try switching the calls and you should see your rollback occur.

	Randy


> -----Original Message-----
> From: Karambir Singh [mailto:ksingh@etouch.net]
> Sent: Friday, February 01, 2002 1:26 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Tyrex transaction in Tomcat
>
>
> I'm using oracle 8.1.6, Tomcat 4.0.1 and tyrex-0.9.7.0.jar.
>
> In newtest.jsp when I try ut.rollback(), it does not
> rollback. The data is
> committed instead.
>
> What could be the problem. Anybody has working code using
> Tyrex Transaction
> framework in Tomcat. Or anybody has a document on how to
> integrate Tomcat4.0
> with Tyrex.
>
>
>
> SERVER.XML
> ----------
> 	<ResourceParams name="jdbc/eTaskPool">
>
> <parameter><name>user</name><value>arch</value></parameter>
>
> <parameter><name>password</name><value>arch</value></parameter>
>             <parameter><name>driverClassName</name>
>
> <value>oracle.jdbc.driver.OracleDriver</value></parameter>
>             <parameter><name>driverName</name>
>
> <value>jdbc:oracle:thin:@tiger:1521:etouch</value></parameter>
>       </ResourceParams>
>
> newtest.jsp
> -----------
>
> <%@ page import="emp, javax.sql.*, java.sql.*, javax.naming.*,
> javax.transaction.*, tyrex.tm.*" %>
>
> <%
> 	out.println("<p>Tomcat-Tyrex Integration Test");
> 	try
> 	{
> 		InitialContext  ctx;
> 		UserTransaction ut;
> 		DataSource      ds;
> 		Connection      conn;
> 		Statement       st;
> 		ResultSet       rs;
>
> 		ctx = new InitialContext();
> 		Context envCtx = (Context) ctx.lookup( "java:/comp/");
> 		ut = (UserTransaction) envCtx.lookup(
> "UserTransaction" );
> 		ds = (DataSource) ctx.lookup(
> "java:/comp/env/jdbc/eTaskPool" );
> 		conn = ds.getConnection();
> 		conn.setAutoCommit(false);
>
> 		ut.begin();
>
> 		st = conn.createStatement();
> 		rs = st.executeQuery( "SELECT EMPNO FROM EMP
> WHERE EMPNO=8" );
> 		if ( rs.next() )
> 		{
> 			out.println( "<p>Current value: " +
> rs.getString( 1 ) );
> 		}
> 		else
> 		{
> 			out.println( "<p>Current value: null" );
> 			st.executeUpdate( "INSERT into EMP values (8)");
> 		}
> 		rs.close();
> 		st.close();
> 		ut.rollback();
>
> 		conn.close();
>
> 		return;
> 	}
> 	catch ( Throwable except )
> 	{
> 		out.println( "<pre>except" );
> 		except.printStackTrace();
> 		out.println( "</pre>" );
> 	}
> %>
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>