Insert row into database with PreparedStatement

前端 未结 3 1757
没有蜡笔的小新
没有蜡笔的小新 2021-01-17 08:32

I want to insert a row into a table using PreparedStatement. The table got 3 columns(int, String, String). The thing is that the int column is AUTO_INCREMENT, so I want to l

3条回答
  •  独厮守ぢ
    2021-01-17 08:53

    That's relatively simple, just leave out the autoincrement column from the column list:

    insert into mytbl(str1, str2) values (?, ?)
    

    Prepare the statement, set the two parameters, and execute in non query mode.

提交回复
热议问题