• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Syntax error in SQL

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
money grubbing section goes here:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic