2 Replies Latest reply on Feb 26, 2003 5:55 PM by rstinejr

    Sybase question

    jgadgil

      I am using Sybase as backend with Jboss 3.0.3-Tomcat4.0.5 integrated bundle. I am getting stuck at this.

      try{
      Context cntx = new InitialContext();
      javax.sql.DataSource dataSource = (javax.sql.DataSource)cntx.lookup(connectionPoolName);
      Conn = dataSource.getConnection();
      Conn.setAutoCommit(false);
      stmt = Conn.createStatement();
      stmt.executeUpdate("update users set loggedin = 1253");
      rst = stmt.executeQuery("Select count(*) as cnt from sysusers");
      rst.next();
      out.println(rst.getInt("cnt"));
      rst.close();
      stmt.executeUpdate("update users set locked = 0");
      Conn.commit();
      stmt.close();
      Conn.close();

      }
      catch(Exception sqle){
      sqle.printStackTrace();
      out.println(sqle.toString());
      }

      Unless I use Conn.setAutoCommit(false) I cant execute the above code. If I make it true and comment out Conn.commit() I get

      com.sybase.jdbc2.jdbc.SybSQLException: SET CHAINED command not allowed within multi-statement transaction

      I downloaded jconnect-5.5 (Sybase JDBC driver) and in the sample directory you have a file ExecuteUpdate.java which does exactly what I want to do but it connects to the DB directly. Is this an APP Server issue then?

      Thanks in Advance.

      Jaideep