Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Syntax error in Insert Into statement

843854May 9 2002 — edited Sep 26 2002
I 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.


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 24 2002
Added on May 9 2002
4 comments
314 views