I am having a problem with a database insert. Here is the code
for the function:
public void executeEFormInsertTest(
String d, String dd,
String ddd, String user, String day1, String code1, String hours1) {
try {
conn = DriverManager.getConnection(DB_DSN,DB_USER,DB_PWD);
pstmt = conn.prepareStatement(insertEFormTest);
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
java.util.Date date1 = sdf.parse(d);
java.util.Date date2 = sdf.parse(dd);
java.util.Date date3 = sdf.parse(ddd);
pstmt.clearParameters();
pstmt.setDate(1, date1);
pstmt.setDate(2, date2);
pstmt.setDate(3, date3);
pstmt.setString(4, user);
pstmt.setString(5, day1);
pstmt.setString(6, code1);
pstmt.setString(7, hours1);
pstmt.executeUpdate();
//pstmt.close();
}
catch(SQLException se) {
System.out.println(se.toString());
}
finally {
if(pstmt !=null) {
try {
pstmt.close();
conn.close();
} catch(Exception e) {
System.out.println("Error while closing db connection");
}
}
}
} // executeEFormInsertTest()
The compiler complains that the [ pstmt.setDate(1,date1); etc..]
calls are not able to be resolved. This is strange to me?? The dates are passed to the function as String objects and I convert them to a java.util.Date using the SimpleDateFormat class.. Any suggestions??