Code:
public void storeRaceResults(float[] times, String event) {
selectTable(event);
try {
for(int i=0; i<8; i++) {
System.out.println(times[i]);//Ovde printa ok vrednost za times[0] i posle toga baca gresku
String query = "update " + tableName + " set time = " + times[i] + " where track = " + (i+1);
int count = st.executeUpdate(query);
}
}
catch(SQLException ex) {
System.err.println("SQLException: Update query failed" + ex.getMessage());
}
}
Ovaj kod treba da upise vremena osam trkaca (sacuvani u times[]) u bazu. Greska nastaje u trenutku prvog izvrsenja upita. Proverio sam varijablu tableName, kao i vrednosti matrice times, sve je OK. Sta bi moglo da bude u pitanju, s obzirom na to da ne baca SQLExcetion, nego NullPointerException ?
public void storeRaceResults(float[] times, String event) {
selectTable(event);
try {
for(int i=0; i<8; i++) {
System.out.println(times[i]);//Ovde printa ok vrednost za times[0] i posle toga baca gresku
String query = "update " + tableName + " set time = " + times[i] + " where track = " + (i+1);
int count = st.executeUpdate(query);
}
}
catch(SQLException ex) {
System.err.println("SQLException: Update query failed" + ex.getMessage());
}
}