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

StackOverflow https://stackoverflow.com/questions/16158651

Question

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
Was it helpful?

Solution

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
);

OTHER TIPS

  PRIMARY KEY ("idTravelerProfile"),
);

The problem is with this very last line. It should not have , before the final ); removing that fixed this error for me.

2 hours later.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top