i'm working at my uni project and i have to make a classbook for a local school.My problem is that i want to insert multiple grades into the grades field.I've tought about making an integer array of the jtestfield.getText() and then converting it to a string so i can insert it into table.
PreparedStatement ps = con.prepareStatement(
"UPDATE elev SET fizica=? WHERE nume=? AND prenume=?");
// nota1=Integer.parseInt(nota.getText());
// ps.setInt(1, nota1);
String sir=nota.getText();
int[] result = Arrays.stream(sir.split(","))
.mapToInt(Integer::parseInt).toArray();
String note=Arrays.toString(result).replaceAll("\\[|\\]|,|\\s", "");
ps.setString(1,note);
ps.setString(2,text.getText());
ps.setString(3, text1.getText());
ps.executeUpdate();
This is the portion of the code but i keep getting java.lang.NullPointerException.
fizicaas an array, and then you can usesetArray()inPreparedStatement. It's harder to query with arrays, though.