Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

'Syntax Error in Query operator' MS Access  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been trying to get a solution to this problem for a while and I think i am getting close.
Basically, I'm trying to delete a record from my MS Access database where the 'Err-Date'(date/time field in format (mm/dd/yyyy)) field matches the date entered into a form by the user. Actually, my main objective is to delete all records that fall within two dates enetred by the user, but for know i'm just trying to get this to work. I beleive I am using the correct String to Date conversion syntax but i am recieveing the following error:
Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Err_Date = Sat Dec 12 00:00:00 PST 1998'.
The date should not be in the above format 'Sat Dec 12 00:00:00 PST 1998'.
Here is my code:
<%@page import="java.sql.*"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="java.util.Date"%>
//define connection
Connection con = null;
//get the class
//get the connection
con = DriverManager.getConnection"jdbc dbc:errorlog", "admin", "");
//please catch your exceptions!
catch(Exception e){
//define resultset and statement
ResultSet rs=null;
Statement stmt=null;
try {
//Using the current database connection create a statement
String start = request.getParameter("From");//TAKEN FROM FORM
String end = request.getParameter("To");//TAKEN FROM FORM
SimpleDateFormat dateFormat = new SimpleDateFormat ("MM/dd/yyyy");
Date date = dateFormat.parse(end);
String sql="DELETE FROM tblError WHERE Err_Date = "+date+"";
rs = stmt.executeQuery(sql);
//close all your open resultsets, statements, and connections
//catch all your exceptions
catch (SQLException e) {
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!