Search code examples
javasqleclipsederby

Why is my Sql code not working in Derby in java?


I am using eclipse and following http://www.eclipse.org/articles/article.php?file=Article-EclipseDbWebapps/index.html and it all works fine except when I try to run my own sql code. Here it is:

CREATE TABLE honscores (
  idhonscores INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
  Name varchar(25) NOT NULL,
  Characters VARCHAR(25) NOT NULL,
  Kills integer(11) NOT NULL,
  Deaths integer(11) NOT NULL,
  Assists integer(11) NOT NULL,
  XPM integer(11) NOT NULL,
  CK integer(11) NOT NULL);

Any help will be appreciated.

Here is the error message :

Syntax error: Encountered "(" at line 5, column 20.

Elapsed Time: 0 hr, 0 min, 0 sec, 0 ms.


Solution

  • CREATE TABLE app.honscores ( //schema name is before the table name
      idhonscores INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
      Name varchar(25) NOT NULL,
      Characters VARCHAR(25) NOT NULL,
      Kills integer NOT NULL,
      Deaths integer NOT NULL,
      Assists integer NOT NULL,
      XPM integer NOT NULL,
      CK integer NOT NULL
    );
    

    Im pretty sure this is how I fixed it