Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 用户活动ID自动增量_Java - Fatal编程技术网

Java 用户活动ID自动增量

Java 用户活动ID自动增量,java,Java,我在从java向mysql中插入值时遇到了问题,它仍然让我对如何插入自动增量感到困惑。有人说,它将自动插入值而不插入值。此外,我还尝试使用addsetint(1,null)并在那里出错 public void mase(){ String time=dateFormat.format(date); String SQLTIME="INSERT INTO history (UserActivityID, UserTimeActivity, UserActivity) VALUES

我在从java向mysql中插入值时遇到了问题,它仍然让我对如何插入自动增量感到困惑。有人说,它将自动插入值而不插入值。此外,我还尝试使用addsetint(1,null)并在那里出错

public void mase(){

   String time=dateFormat.format(date);

   String SQLTIME="INSERT INTO history (UserActivityID, UserTimeActivity, UserActivity) VALUES (null,?,?)";

try {
    JOptionPane.showMessageDialog(this, "?");

    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/atm?zeroDateTimeBehavior=convertToNull", "root", "");
    PreparedStatement prstm=con.prepareStatement(SQLTIME);
    prstm = con.prepareStatement(SQLTIME,PreparedStatement.RETURN_GENERATED_KEYS);

    prstm.setString(1, time);
    prstm.setString(2,"Cash Withdraw");
    int rowsInserted = prstm.executeUpdate();
    if (rowsInserted > 0) {

     JOptionPane.showMessageDialog(this," inserted successfully!");
     }

} catch (SQLException | HeadlessException | ClassCastException ex) {
    JOptionPane.showMessageDialog(this, ex); 
}
    JOptionPane.showMessageDialog(this, time); 

}

从命令中排除
用户活动ID
,DB管理器将为您插入该ID

String SQLTIME=“插入历史记录(UserTimeActivity,UserActivity)值(?,)”