Problem with SQL code while using Java DB. Saying parentheses is foreign

49 views Asked by At

I am new to java. I am trying to create two SQL codes to create a table in Java DB (I am using NetBeans 12.5). I set it up how I thought it should be set up but I am still getting an error.

CREATE TABLE CheckInLocation(
    CheckInLocationID int NOT NULL PRIMARY KEY,
    StationName VARCHAR(30) NOT NULL,
);

CREATE TABLE Passenger (
    PassengerID int NOT NULL PRIMARY KEY,
    FirstName VARCHAR(30) NOT NULL,
    LastName VARCHAR(30) NOT NULL,
    CheckInDateTime TIMESTAMP NOT NULL,
    FOREIGN KEY (CheckInLocationID) REFERENCES CheckInLocation(CheckInLocationID),
);

The error I am getting is this:

[Exception, Error code 30,000, SQLState 42X01] Syntax error: Encountered ")" at line 7, column 1.

Any help at all I will appreciate. Thank you.

1

There are 1 answers

0
Chondrom Pala On

Problem is the final comma in both your create tables. For example, replace

StationName VARCHAR(30) NOT NULL,

with

StationName VARCHAR(30) NOT NULL