Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Syntax error in SQL

 
Femi Ojambati
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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

means,

[Member ID] is incorrect field name
[Member_ID] is correct.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic