Search code examples
javasqlderby

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.


Solution

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