473,289 Members | 1,848 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,289 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 8858
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.