473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 8866
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

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

Similar topics

3
by: Andrew | last post by:
I have a problem creating mySQL tables with PHP. I am making an app where a user can create a project. Pressing "submit" on proj_form.php goes to proj_add.php where a couple of things happen. ...
0
by: Morten Gulbrandsen | last post by:
USE company; DROP TABLE IF EXISTS EMPLOYEE; CREATE TABLE EMPLOYEE ( # PK SSN CHAR(9) NOT NULL, # FK SUPERSSN CHAR(9), DNO INT NOT NULL DEFAULT 1, CONSTRAINT EMPPK
4
by: Michael Jackson | last post by:
I have a stored procedure to create a table. In my program I want the user to name the table to be created, therefore I pass a parameter to the SP for the table name. I cannot get it to work. It...
2
by: Karen Sullivan | last post by:
Hi, all. I'm fairly new to SQL, and I have been trying to create a table from a text file. I have been looking at this for days, and can't find the problem. I get a syntax error " Line 55:...
6
by: Bruce | last post by:
I want to create a new table based on an existing table, but I don't want the tables to have any enforced relationship. Is this possible without having to do a CREATE TABLE and an INSERT? ...
2
by: Alicia | last post by:
Does anyone know why I am getting a "Syntax error in Create Table statement". I am using Microsoft Access SQL View to enter it. Any other problems I may run into? CREATE TABLE weeks (...
6
by: Peter Nurse | last post by:
For reasons that are not relevant (though I explain them below *), I want, for all my users whatever privelige level, an SP which creates and inserts into a temporary table and then another SP...
3
by: SteveP26 | last post by:
Hi guys, I keep getting this error message (below) when I try to run the sql query for my database Heres the code, but the error message only applies to the LAST table (SalesCopy), I have no...
2
jbt007
by: jbt007 | last post by:
All, Access 2003 - WinXP I thought this would be a no brainer, but it seems to be a perplexing problem. I have a simple table I use for importing several text reports, use VBA to run through...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.