So I have a method for updating some fields in a MS Access 2007 table, and whenever I try to update I get the following exception: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 11. It always shows that one more is expected than there are in the query.
The code of the method is:
try {
String upit = "UPDATE Izlagac SET NazivIzlagaca=?, PIB=?, Telefon=?, "
+ " KontaktOsoba=?, Email=?, TipIzlagaca=?, Ulica=?, Broj=?, Mesto=?, Drzava=? WHERE "
+ " SifraIzlagaca = " + i.getSifraIzlagaca() + ";";
PreparedStatement pstmt = con.prepareStatement(upit);
pstmt.setString(1, i.getNazivIzlagaca());
pstmt.setString(2, i.getPIB());
pstmt.setString(3, i.getTelefon());
pstmt.setString(4, i.getKontaktOsoba());
pstmt.setString(5, i.getEmail());
pstmt.setString(6, i.getTipIzlagaca());
pstmt.setString(7, i.getUlica());
pstmt.setString(8, i.getBroj());
pstmt.setString(9, i.getMesto());
pstmt.setString(10, i.getDrzava());
System.out.println(pstmt.toString());
pstmt.executeUpdate();
pstmt.close();
return true;
} catch (SQLException ex) {
Logger.getLogger(DBBroker.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
I am not using aliases so that doesn't seem to be the reason why the driver would expect additional parameter. All the column names are correctly spelled, triple checked it.
i.getSifraIzlagaca()does not happen to return a question mark, right?... WHERE SifraIzlagaca = ?andpstmt.setString(11, i.getSifraIzlagaca());?