In JavaDB apache derby I dont know what is causing a Error: Syntax error: Encountered ")" at line 30, column 1. SQLState: 42X01

nelaaro picture nelaaro · Apr 23, 2013 · Viewed 8.8k times · Source
CREATE TABLE "TravelerProfile" (
  "idTravelerProfile" int NOT NULL,
  "AccountID" int NOT NULL,
  "GivenName" varchar(45) DEFAULT NULL,
  "FamilyName" varchar(45) DEFAULT NULL,
  "Title" varchar(45) DEFAULT NULL,
  "Department" varchar(45) DEFAULT NULL,
  "Position" varchar(45) DEFAULT NULL,
  "TravelBooker" varchar(45) DEFAULT NULL,
  "IDnumber" varchar(10) DEFAULT NULL,
  "BusinessAddress" varchar(255) DEFAULT NULL,
  "BusinessPhone" varchar(12) DEFAULT NULL,
  "BusinessFax" varchar(12) DEFAULT NULL,
  "BusinessEmail" varchar(45) DEFAULT NULL,
  "HomeAddress" varchar(255) DEFAULT NULL,
  "HomePhone" varchar(12) DEFAULT NULL,
  "HomeEmail" varchar(45) DEFAULT NULL,
  "MobilePhone" varchar(12) DEFAULT NULL,
  "SpouseName" varchar(45) DEFAULT NULL,
  "SpouseContactNumber" varchar(45) DEFAULT NULL,
  "SpouseEmail" varchar(45) DEFAULT NULL,
  "DoctorsName" varchar(45) DEFAULT NULL,
  "DoctorsConctactNumber" varchar(45) DEFAULT NULL,
  "DoctorsEmail" varchar(45) DEFAULT NULL,
  "KnownMedicalConditions" varchar(512) DEFAULT NULL,
  "AttachmentID" varchar(45) DEFAULT NULL,
  "DateCreated" timestamp  DEFAULT NULL,
  "DateModified" timestamp  DEFAULT NULL,
  PRIMARY KEY ("idTravelerProfile"),
);

I keep getting this error.

Error: Syntax error: Encountered ")" at line 30, column 1.
SQLState:  42X01
ErrorCode: -1

Answer

John Woo picture John Woo · Apr 23, 2013

because you have extra comma after the PRIMARY KEY which needs to be removed

   "DateModified" timestamp  DEFAULT NULL,
   PRIMARY KEY ("idTravelerProfile"),       -- <<== remove this trailing comma
);