469,360 Members | 1,728 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

derby create table

oll3i
679 512MB
my function connects to the database but the tables are not created?
i get Syntax error: Encountered "<EOF>" at line 1, column 187.


part of my function that is supposed to create the tables
Expand|Select|Wrap|Line Numbers
  1.  try
  2.              {
  3.                  int count=statement.executeUpdate("CREATE TABLE contacts("+
  4.                    "CONTACT_ID INTEGER NOT NULL PRIMARY KEY, "+
  5.                    "FIRSTNAME VARCHAR(25) not null, "+
  6.                    "LASTNAME VARCHAR(25) not null, "+
  7.                    "EMAIL VARCHAR(60) not null, "+
  8.                    "CONSTRAINT UNIQUE_EMAIL UNIQUE(EMAIL)");
  9.  
  10.                  System.out.println("Table contacts created="+count);
  11.  
  12.  
  13.  
  14.                  count=statement.executeUpdate("create table BOOKS("+
  15.                 "BOOK_ID INTEGER NOT NULL PRIMARY KEY, "+
  16.                  "AUTHOR VARCHAR(100) not null, "+
  17.                 "TITLE VARCHAR(100) not null, "+
  18.                 "ISBN VARCHAR(10) not null, "+
  19.                  "ISSUE_YEAR SMALLINT not null, "+
  20.                  "CONSTRAINT UNIQUE_ISBN UNIQUE(ISBN)");
  21.  
  22.                  System.out.println("Table books created="+count);
  23.              }
  24.              catch (SQLException ex)
  25.              {
  26.               System.out.println(ex.getMessage());
  27.              }
  28.  
  29.  
Nov 13 '08 #1
8 8241
JosAH
11,448 Expert 8TB
Cute, which one of the two statements failed?

kind regards,

Jos
Nov 13 '08 #2
oll3i
679 512MB
the first one
when i try to return rows from the table it says that the table does not exist
connection to the database doesn't throw any errors (had classNotFoundException before)
Nov 14 '08 #3
JosAH
11,448 Expert 8TB
the first one
when i try to return rows from the table it says that the table does not exist
connection to the database doesn't throw any errors (had classNotFoundException before)
Well, the SQL parser complained about a syntax error near column 187; all you
have to do is count and spot the error (it's a missing right parenthesis). You could
have known that if you had read the error message.

kind regards,

Jos
Nov 14 '08 #4
r035198x
13,262 8TB
Are you sure that

1.) The connection code is successful(i.e make sure there are no empty catch blocks on the connection code).
2.) You are proving the correct table name(s) when doing the select?
Nov 14 '08 #5
r035198x
13,262 8TB
Well, the SQL parser complained about a syntax error near column 187; all you
have to do is count and spot the error (it's a missing right parenthesis). You could
have known that if you had read the error message.

kind regards,

Jos
Duh, I seem to have missed that first post.
Nov 14 '08 #6
JosAH
11,448 Expert 8TB
Duh, I seem to have missed that first post.
It ain't over yet because now that second SQL statement is going to act up;
let's see if the OP can spot the error ;-)

kind regards,

Jos
Nov 14 '08 #7
oll3i
679 512MB
i dont see the error maybe you will spot it i stare at it and see nothing

Expand|Select|Wrap|Line Numbers
  1.  int count=statement.executeUpdate(
  2.                    "CREATE TABLE CONTACTS ( " 
  3.                    + "CONTACT_ID INT NOT NULL GENERATED ALWAYS AS IDENTITY CONSTRAINT CONTACT_PK PRIMARY KEY (START WITH 1, INCREMENT BY 1), "
  4.                    + "FIRSTNAME  VARCHAR(25) NOT NULL, " 
  5.                    + "LASTNAME  VARCHAR(25) NOT NULL, " 
  6.                    + "EMAIL VARCHAR(60) NOT NULL, " 
  7.                    + "CONSTRAINT UNIQUE_EMAIL UNIQUE(EMAIL))");
  8.  
i get Syntax error: Encountered "(" at line 1, column 112.|#
thank You thank You thank You :)
Nov 14 '08 #8
r035198x
13,262 8TB
Put that sql in a string variable and System.out.println the sql before executing it to see what's passed to the database.
Nov 17 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Andrew | last post: by
4 posts views Thread by Michael Jackson | last post: by
2 posts views Thread by Karen Sullivan | last post: by
6 posts views Thread by Bruce | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.