Error when exeuting SQL commands: Error code -1, SQL state 42x02: Lexical error at ..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gilsaa
    New Member
    • Apr 2014
    • 1

    Error when exeuting SQL commands: Error code -1, SQL state 42x02: Lexical error at ..

    Hi
    I'm trying to make following table in java(netbeans):
    Code:
    DROP TABLE "Userdata";
    DROP TABLE "ChargeHistory";
    DROP TABLE "Price";
    
    CREATE TABLE “Userdata” (
       “UserID” varchar (8) NOT NULL,
       "firstName" varchar (20) NOT NULL,
       "lastName" varchar (30) NOT NULL,
       “AccountBalance” double NOT NULL,
       “UserPIN” int NOT NULL,
       PRIMARY KEY (“UserID”)
    );
    
    CREATE TABLE “ChargeHistory” (
       “UserID” varchar (8) NOT NULL,
       “Date” varchar (20) NOT NULL,
       “ChargeAmountDKK” double NOT NULL,
       “ChargeAmountkWh” double NOT NULL,
       FOREIGN KEY (“UserID”) REFERENCES “Userdata” (“UserID”)
    );
    
    CREATE TABLE “Price” (
       “Date” varchar (20) NOT NULL,
       “Price” double NOT NULL,
       PRIMARY KEY (“Date”)
    );
    But when I try to run the commands, I get en Lexical error for each of the tables that I'm trying to make.
    Can someone pleasë help

    Thanks
    Last edited by Rabbit; Apr 28 '14, 03:37 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    On the first look, the SQL staements seem to be OK.
    Can you please post the exact error message?
    There could be issues by not escaping the double quotation marks or running more than one statement at one etc., but that is just a guessing game until you provide the exact error message.

    And with what tool (where) you run them? How do you do that exactly? Can you please describe further?

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Please use code tags when posting code or formatted data.

      I see different types of double quotes in your code. Make sure you are using " and not “”. They are not the same. They probably came from copied code on the internet.

      Comment

      • chaarmann
        Recognized Expert Contributor
        • Nov 2007
        • 785

        #4
        Wow, Rabbit, you have eagle eyes!

        A friend of mine spent ages to run code that he typed containing "O" instead of "0" and "I" instead of "1" or "|"

        Comment

        Working...