56gt 发表于 2018-10-1 14:32:05

MySQL开启RewriteBatchedStatements后PreparedStatement的一个异常

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

  
public class Demo
  
{
  
    public static final String DBDRIVER = "com.mysql.jdbc.Driver";
  
    public static final String DBURL = "jdbc:mysql://127.0.0.1:3306/S10?rewriteBatchedStatements=true";
  
    public static final String DBUSER = "root";
  
    public static final String DBPASS = "123456";
  

  
    public static void main(String[] args)
  
    {
  
      try
  
      {
  
            Class.forName(DBDRIVER);
  
            try (Connection conn = DriverManager.getConnection(DBURL, DBUSER, DBPASS);
  
                  PreparedStatement pstmt = conn.prepareStatement(
  
                            "INSERT INTO _1033 SET F01 = ?, F02 =? ON DUPLICATE KEY UPDATE F02 = VALUES(F02)"))
  

  
            {
  
                pstmt.setLong(1, 1);
  
                pstmt.setString(2, "2");
  
                pstmt.executeUpdate();
  
            }
  
            catch (Exception e)
  
            {
  
                e.printStackTrace();
  
            }
  
      }
  
      catch (ClassNotFoundException e)
  
      {
  
            e.printStackTrace();
  
      }
  
    }
  
}


页: [1]
查看完整版本: MySQL开启RewriteBatchedStatements后PreparedStatement的一个异常