Bug #29787 stmt.executeUpdate() return wrong affect number.
Submitted: 13 Jul 2007 12:53 Modified: 17 Jul 2007 8:58
Reporter: Huang wen hui Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.1.20 OS:FreeBSD (FreeBSD/amd64 Linux/amd64)
Assigned to: CPU Architecture:Any

[13 Jul 2007 12:53] Huang wen hui
Description:
stmt.executeUpdate() always return wrong number.
version below 5.1.20 does not have this problem.

test program:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class TestPy {

	public TestPy() {
	}

	public void test() throws Exception {
		String jdbcDriver = "com.mysql.jdbc.Driver";
		String dbURL = "jdbc:mysql://localhost/test?user=root&password=rootme";
		Connection conn = null;
		PreparedStatement stmt = null;//
		
		try {
			Class.forName(jdbcDriver).newInstance();
			conn = DriverManager.getConnection(dbURL);
			conn.setAutoCommit(true);
      stmt = conn
      .prepareStatement("INSERT INTO auto_test (v) VALUES (?)");
      stmt.setString(1, "GD");
      //stmt.addBatch();
			int n = stmt.executeUpdate();
      System.out.println("n: "+n);
		} catch (java.sql.SQLException sqlEx) {
			sqlEx.printStackTrace();
		} finally {
			if (stmt != null) {
				try {
					stmt.close();
				} catch (SQLException sEx) {
				}
			}
			if (conn != null) {
				try {
					conn.close();
				} catch (SQLException sEx) {
				}
			}
		}

	}

	public static void main(String[] args) throws Exception {
		TestPy testPy1 = new TestPy();
		testPy1.test();
	}
}

How to repeat:
run this test case.
[13 Jul 2007 13:02] Huang wen hui
same as ID 29692.
[17 Jul 2007 8:56] Sveta Smirnova
test case

Attachment: bug29787.c (text/plain), 1.65 KiB.

[17 Jul 2007 8:58] Sveta Smirnova
Thank you for the report.

Investigating with attached C API test case shows this is duplicate of Bug #29692.