Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ERROR: java.sql.SQLException:[ODBC MS Access Driver] Syntax Error

Status
Not open for further replies.

Tango524

Technical User
Mar 10, 2003
25
0
0
US
Hi All-

I am trying to create a table and insert values into an Access database with Java. My java program will compile, but I receive this error when I try to run the program:

ERROR: java.sql.SQLException:[ODBC Microsoft Access Driver] Syntax Error in field definition

I am not sure if I am setting up my ODBC driver correctly. Any suggestions in setting up my driver?? I have some of the java program here for my obdc connection as well.


String url = "jdbc:eek:dbc:CLCDB";
String myForm;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con = DriverManager.getConnection(url);

Thanks a bunch!
 
I don't this the problem is with the connection to the databse, maybe the problem is with the create/insert statement. Could you please provide the insert and create statements to do further research?
 
Sure! Thanks in advance for all your help! These statements follow the statements above.

Statement s = con.createStatement();

s.executeUpdate("create table myForm (date varchar(20), name varchar(50);");

s.executeUpdate("insert into myForm values('2/2/02','John Doe');");

s.close();
con.close();
 
Sorry I didn't notice your reply...

The problems is actually in your create statement, I noticed two issue:

1. You can not use "date" as a column name since it is a reserved word in Access. Trying use "DateAdded" instead.

2. You are missing a ) on the end. The SQL Statement should look something like this:

s.executeUpdate("CREATE TABLE myForm (DateAdded varchar(20), name varchar(50));");

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top