I have the following method, what I don't understand is how I need to process the statement. Can anybody direct me on how to do this?
Thanks
public void updateStudentInformation(StudentInformation stInformation) throws Exception {
if (conn != null) {
try {
PreparedStatement ps;
ps = conn.prepareStatement(
"UPDATE STUDENT_INFORMATION " +
"SET " +
"LANGUAGE1 = ? " +
",WR_LANG1 = ? " +
",SP_LANG1 = ? " +
",LANGUAGE2 = ? " +
",WR_LANG2 = ? " +
",SP_LANG2 = ? " +
",LANGUAGE3 = ? " +
",WR_LANG3 = ? " +
",SP_LANG3 = ? " +
",CAR = ? " +
",PDSB = ? " +
",DATE_MODIFIED = (SELECT SYSDATE FROM DUAL) " +
"WHERE STUDENT_ID = ? "
ps.setInt(1, stInformation.getLanguage1());
ps.setInt(2, stInformation.getWritingLanguage1());
ps.setInt(3, stInformation.getSpokenLanguage1());
ps.setInt(4, stInformation.getLanguage2());
ps.setInt(5, stInformation.getWritingLanguage2());
ps.setInt(6, stInformation.getSpokenLanguage2());
ps.setInt(7, stInformation.getLanguage3());
ps.setInt(8, stInformation.getWritingLanguage3());
ps.setInt(9, stInformation.getSpokenLanguage3());
ps.setString(10, stInformation.getCar());
ps.setString(11, stInformation.getPDSB());
ps.setInt(12, stInformation.getID());
ps.execute();
} // End try
catch (SQLException sqle) {
error = "SQLException: update failed.";
throw new SQLException(error);
}
}
else {
error = "Exception: Connection to database was lost.";
throw new Exception(error);
}
}// End updateStudentInformation
===========================================================
public class StudentInformation {
public int lang1;
public int wr_lang1;
public int sp_lang1;
public int lang2;
public int wr_lang2;
public int sp_lang2;
public int lang3;
public int wr_lang3;
public int sp_lang3;
public String car;
public String pdsb;
public int id;
// Language 1
public int getLanguage1() {
return lang1;
}
public int getWritingLanguage1() {
return wr_lang1;
}
public int getSpokenLanguage1() {
return sp_lang1;
}
// Language 2
public int getLanguage2() {
return lang2;
}
public int getWritingLanguage2() {
return wr_lang2;
}
public int getSpokenLanguage2() {
return sp_lang2;
}
// Language 3
public int getLanguage3() {
return lang3;
}
public int getWritingLanguage3() {
return wr_lang3;
}
public int getSpokenLanguage3() {
return sp_lang3;
}
// Car
public String getCar() {
return car;
}
// PDSB
public String getPDSB() {
return pdsb;
}
// ID
public int getID() {
return id;
}
}
Thanks
public void updateStudentInformation(StudentInformation stInformation) throws Exception {
if (conn != null) {
try {
PreparedStatement ps;
ps = conn.prepareStatement(
"UPDATE STUDENT_INFORMATION " +
"SET " +
"LANGUAGE1 = ? " +
",WR_LANG1 = ? " +
",SP_LANG1 = ? " +
",LANGUAGE2 = ? " +
",WR_LANG2 = ? " +
",SP_LANG2 = ? " +
",LANGUAGE3 = ? " +
",WR_LANG3 = ? " +
",SP_LANG3 = ? " +
",CAR = ? " +
",PDSB = ? " +
",DATE_MODIFIED = (SELECT SYSDATE FROM DUAL) " +
"WHERE STUDENT_ID = ? "
ps.setInt(1, stInformation.getLanguage1());
ps.setInt(2, stInformation.getWritingLanguage1());
ps.setInt(3, stInformation.getSpokenLanguage1());
ps.setInt(4, stInformation.getLanguage2());
ps.setInt(5, stInformation.getWritingLanguage2());
ps.setInt(6, stInformation.getSpokenLanguage2());
ps.setInt(7, stInformation.getLanguage3());
ps.setInt(8, stInformation.getWritingLanguage3());
ps.setInt(9, stInformation.getSpokenLanguage3());
ps.setString(10, stInformation.getCar());
ps.setString(11, stInformation.getPDSB());
ps.setInt(12, stInformation.getID());
ps.execute();
} // End try
catch (SQLException sqle) {
error = "SQLException: update failed.";
throw new SQLException(error);
}
}
else {
error = "Exception: Connection to database was lost.";
throw new Exception(error);
}
}// End updateStudentInformation
===========================================================
public class StudentInformation {
public int lang1;
public int wr_lang1;
public int sp_lang1;
public int lang2;
public int wr_lang2;
public int sp_lang2;
public int lang3;
public int wr_lang3;
public int sp_lang3;
public String car;
public String pdsb;
public int id;
// Language 1
public int getLanguage1() {
return lang1;
}
public int getWritingLanguage1() {
return wr_lang1;
}
public int getSpokenLanguage1() {
return sp_lang1;
}
// Language 2
public int getLanguage2() {
return lang2;
}
public int getWritingLanguage2() {
return wr_lang2;
}
public int getSpokenLanguage2() {
return sp_lang2;
}
// Language 3
public int getLanguage3() {
return lang3;
}
public int getWritingLanguage3() {
return wr_lang3;
}
public int getSpokenLanguage3() {
return sp_lang3;
}
// Car
public String getCar() {
return car;
}
// PDSB
public String getPDSB() {
return pdsb;
}
// ID
public int getID() {
return id;
}
}