When I run my program, it show the error the column is out of range. Connection is ok
For exmaple
updateRecoredtoStudent(15, "Annies","Bot"," Ionia", "1/1/2013","firstname","Anny")
private static void updateRecordToStudent(int studentid, String firstname, String lastname,String address, String dateofbirth, String cond_col, String cond_val) throws SQLException {
Connection dbConnection = null;
PreparedStatement preparedStatement = null;
String updateTableSQL = "UPDATE student SET 'studentid' = ? 'firstname' = ? 'lastname' = ? 'address' = ? dateofbirth' = ? WHERE ? = ?";
try {
dbConnection = getDBConnection();
preparedStatement = dbConnection.prepareStatement(updateTableSQL);
preparedStatement.setInt(1, studentid);
preparedStatement.setString(2, firstname);
preparedStatement.setString(3, lastname);
preparedStatement.setString(4, address);
preparedStatement.setString(5, dateofbirth);
preparedStatement.setString(6, cond_col);
preparedStatement.setString(7, cond_val);
// execute update SQL stetement
preparedStatement.executeUpdate();
System.out.println("Record is updated to STUDENT table!");
} catch (SQLException e) {
System.out.println(e.getMessage());
} finally {
if (preparedStatement != null) {
preparedStatement.close();
}
if (dbConnection != null) {
dbConnection.close();
}
}
}
Student table contains
-studentid(int-PK)
-Firstname(String)
-lastname(String)
-Address(String)
-Dateofbirth(String)