tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karambir Singh" <ksi...@etouch.net>
Subject Tyrex Transaction in Tomcat 4.0
Date Fri, 01 Feb 2002 02:26:35 GMT

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:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message