7 messages in com.mysql.lists.javaRe: Autocommit is not working ??
FromSent OnAttachments
Mufaddal Khumri21 Aug 2003 00:59 
Mufaddal Khumri21 Aug 2003 01:16 
Mufaddal Khumri21 Aug 2003 01:22 
Jeff Mathis21 Aug 2003 13:31 
Jeff Mathis21 Aug 2003 13:43 
Allen Weeks21 Aug 2003 13:52 
Jeff Mathis21 Aug 2003 14:05 
Subject:Re: Autocommit is not working ??
From:Jeff Mathis (jmat@predict.com)
Date:08/21/2003 01:31:58 PM
List:com.mysql.lists.java

Are you using InnoDB tables?

Mufaddal Khumri wrote:

Hi ..

I was setting the auto commit to false below and doing a query to the mysql database. I return without making an explicit call to con.commit(). The data still gets entered in the database .. why ?????

I am using mysql driver 3.0.6 stable build with mysql database version 11.18 Distrib 3.23.55, for apple-darwin6.3.

Does anybody know what am I doing wrong ?

Thanks.

public void someMethod( .... ) { Connection con = cp.allocate();

try { con.setAutoCommit(false);

// Enter response in the Response Table. PreparedStatement pstmt = con.prepareStatement("INSERT INTO RESPONSE " + "(USERID,
TYPE)" + " VALUES
(?,?)");

pstmt.setInt(1, r.getUserId()); pstmt.setInt(2, r.getType());

pstmt.executeUpdate(); pstmt.close();

flag = true; return true;

//con.commit(); //con.setAutoCommit(true); //flag = true; } catch(SQLException ex) { ex.printStackTrace(); flag = false; }

cp.free(con);

return flag; }