Using TO_DATE with a prepared statement
843859Aug 31 2005 — edited Aug 31 2005Hi all,
I'm grabbing information from a form and putting it into the database. I keep on getting a sql exception: java.sql.SQLException: ORA-00947: not enough values. What am I doing wrong, or is my thinking completely wrong with doing TO_DATE and a prepared statement? Thanks all.
java.util.Date d = new java.util.Date();
String month = String.valueOf(d.getMonth() + 1);
String day = String.valueOf(d.getDate());
String year = String.valueOf(d.getYear() + 1900);
String date = month+"/"+day+"/"+year;
String individual = request.getParameter("responsible_individual");
String item = request.getParameter("action_item");
String target = request.getParameter("target_date");
String status_date = request.getParameter("report_status_date");
String committee = request.getParameter("responsible_committee");
PreparedStatement cursor =
connection.prepareStatement("INSERT INTO ncci_item VALUES (TO_DATE(?,'MM/DD/YYYY'), ?, ?, ?, ?, ?, 'true')");
cursor.setString(1, date);
cursor.setString(2, individual);
cursor.setString(3, item);
cursor.setString(4, target);
cursor.setString(5, status_date);
cursor.setString(6, committee);
cursor.executeUpdate();