Syntax error in Insert Into statement
843854May 9 2002 — edited Sep 26 2002I cannot figure out why I am getting a Micorsoft Access Driver Syntax error in Insert Into Statement. Below is part of my code. Any insight would greatly be appreciated.
Calendar date = Calendar.getInstance();
day = date.get(Calendar.DATE); //returns current day
month = date.get(Calendar.MONTH)+1; //returns month
year = date.get(Calendar.YEAR); //return year
systemDate = month + "/"+day+"/"+year;
String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driverName);
System.out.println("connecting to database");
String databaseURL = "jdbc:odbc:Acom";
Connection c = DriverManager.getConnection(databaseURL);
Statement s = c.createStatement();
//begin creating sql statement
String fields = "email, fullName, address1, address2, company, city, state, zipcode, phone, fax, training, date";
String values = "'"+email+"', '"+fullName+"', '"+address1+"', '"+address2+"', '"+company+"', '"+city+"', '"+state+"', '"+zipcode+"', '"+phone+"', '"+fax+"', '"+id+"', '"+systemDate+"'";
String sql="INSERT INTO CustomerInfo("+fields+") VALUES ("+values+");";
int rowsUpdated = s.executeUpdate(sql);
The insert statement works fine until I add the date field, and systemDate value. I am inserting into Access 2000 and the date field is text.