Why my pk will not auto ++ in my database? I want to let my ok auto +1 every time when I insert new details to the database…
public void generatePK(){
try{
rsCombineItem = stmtSearch.executeQuery("SELECT * FROM CombineItem;");
while(rsCombineItem.next()){
this.pk = rsCombineItem.getInt(1);
}
this.pk+=1;
}
catch(Exception e){
JOptionPane.showMessageDialog(null,e);
}
}
This is something that you need to set up on the database side, and not in your code. Set the column in your database as primary key, and to auto increment! See the example to see an example using SQL Server.