473,545 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

derby create table

oll3i
679 Contributor
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 8881
JosAH
11,448 Recognized Expert MVP
Cute, which one of the two statements failed?

kind regards,

Jos
Nov 13 '08 #2
oll3i
679 Contributor
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 classNotFoundEx ception before)
Nov 14 '08 #3
JosAH
11,448 Recognized Expert MVP
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 classNotFoundEx ception 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 MVP
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 MVP
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 Recognized Expert MVP
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 Contributor
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 MVP
Put that sql in a string variable and System.out.prin tln 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
3589
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. The project's meta information is put into a project table, mysql_insert_id() gets the $proj_ID, and a table named that $proj_ID is created to hold...
0
1162
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
4429
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 creates a table called "@NewTableName". Any ideas? CREATE PROCEDURE dbo.sp_FFProduction_CreateTable (
2
5135
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: Incorrect syntax near 'DateUpdated'." Here is the query. Any suggestions would be appreciated, as I am trying to learn and improve. Use ACH go ...
6
12267
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? create table customer_Temp as (select credit_Card_number, personal_id_number from customer) DATA INITIALLY DEFERRED REFRESH deferred; refresh table...
2
13912
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 ( weekstart datetime not null primary key, weekend datetime not null )
6
7698
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 which reads and drops the same temporary table. My users are not able to create dbo tables (eg dbo.tblTest), but are permitted to create tables under...
3
4584
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 clue how its any different than the others. SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
2
3375
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 the report to move data into tables. The temp table stays in access (tblTxtRpt), until the next report is imported, I then use SQL to DROP TABLE and...
0
7470
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7405
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7659
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7428
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5975
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5334
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1887
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1019
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
709
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.