aspose file tools*
The moose likes JDBC and the fly likes Syntax error in SQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Syntax error in SQL" Watch "Syntax error in SQL" New topic
Author

Syntax error in SQL

Femi Ojambati
Greenhorn

Joined: Aug 13, 2008
Posts: 6
Please check this code.


...
Statement stat = conn.createStatement();
String query = "CREATE TABLE Table1(Member ID No INTEGER NOT NULL PRIMARY KEY, Surname VARCHAR(30), Other Names VARCHAR(30), Date of Entry DATE)";
int result = stat.executeUpdate(query);

query = "INSERT INTO Table1 (Member ID No, Surname, Other Names, Date of Entry)
VALUES (001, 'Ojambati', 'Oluwafemi Stephen', '2008-10-15')";
result = stat.executeUpdate(query);

When I tried to run it
An exception was caught, this message was displayed

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

Please where is the error in this code
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321



because SQL doesn't allow the space in Field Name.

means,

[Member ID] is incorrect field name
[Member_ID] is correct.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Syntax error in SQL