This question already has an answer here:
- SQL INSERT without specifying columns. What happens? 6 answers
My program always reads the first column in the Access database as the 2nd column, the 2nd one as the 3rd column and so on, but the last column it reads as the first column.
public void actionPerformed(ActionEvent e) {
try{
String query = "insert into Staff values ('2', 'w', 'w', 'w', 'e', 'w', 'd','d','end')";
stmt.executeUpdate(query);
status.setText("1 row of record have been inserted");
}catch(Exception ex){
ex.printStackTrace();
}
}
But when i specify the column names, it reads normally
public void actionPerformed(ActionEvent e) {
try{
String query = "insert into Staff (id, lastName, firstName, mi, address, city, state, telephone, email) "
+ "values ('2', 'w', 'w', 'w', 'e', 'w', 'd','d','end')";
stmt.executeUpdate(query);
status.setText("1 row of record have been inserted");
}catch(Exception ex){
ex.printStackTrace();
}
}