farhan ansari
farhan ansari

Reputation: 21

SQL statement SQLSyntaxErrorException

I'm getting an error executing the following SQL statement:

String sql = "CREATE TABLE RESERVATION (";
sql = sql + " UID VARCHAR,";
sql = sql + " ISBN INTEGER,";
sql = sql + " DATEISSUE DATE,";
sql = sql + " DATERETURN DATE,";
sql = sql + " FOREIGN KEY (UID) REFERENCES USERS (UID),";
sql = sql + " FOREIGN KEY (ISBN) REFERENCES BOOKS (ISBN) )";

Here is the error I am getting:

java.sql.SQLSyntaxErrorException: Syntax error: Encountered "," at line 1, column 39.

Upvotes: 1

Views: 66

Answers (1)

paxdiablo
paxdiablo

Reputation: 881363

Column 39 is near the end of the varchar, so you probably need a size for it, such as varchar(20).

Upvotes: 2

Related Questions