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 -
try
-
{
-
int count=statement.executeUpdate("CREATE TABLE contacts("+
-
"CONTACT_ID INTEGER NOT NULL PRIMARY KEY, "+
-
"FIRSTNAME VARCHAR(25) not null, "+
-
"LASTNAME VARCHAR(25) not null, "+
-
"EMAIL VARCHAR(60) not null, "+
-
"CONSTRAINT UNIQUE_EMAIL UNIQUE(EMAIL)");
-
-
System.out.println("Table contacts created="+count);
-
-
-
-
count=statement.executeUpdate("create table BOOKS("+
-
"BOOK_ID INTEGER NOT NULL PRIMARY KEY, "+
-
"AUTHOR VARCHAR(100) not null, "+
-
"TITLE VARCHAR(100) not null, "+
-
"ISBN VARCHAR(10) not null, "+
-
"ISSUE_YEAR SMALLINT not null, "+
-
"CONSTRAINT UNIQUE_ISBN UNIQUE(ISBN)");
-
-
System.out.println("Table books created="+count);
-
}
-
catch (SQLException ex)
-
{
-
System.out.println(ex.getMessage());
-
}
-
-
8 8867
Cute, which one of the two statements failed?
kind regards,
Jos
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)
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
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?
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.
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
i dont see the error maybe you will spot it i stare at it and see nothing -
int count=statement.executeUpdate(
-
"CREATE TABLE CONTACTS ( "
-
+ "CONTACT_ID INT NOT NULL GENERATED ALWAYS AS IDENTITY CONSTRAINT CONTACT_PK PRIMARY KEY (START WITH 1, INCREMENT BY 1), "
-
+ "FIRSTNAME VARCHAR(25) NOT NULL, "
-
+ "LASTNAME VARCHAR(25) NOT NULL, "
-
+ "EMAIL VARCHAR(60) NOT NULL, "
-
+ "CONSTRAINT UNIQUE_EMAIL UNIQUE(EMAIL))");
-
i get Syntax error: Encountered "(" at line 1, column 112.|#
thank You thank You thank You :)
Put that sql in a string variable and System.out.println the sql before executing it to see what's passed to the database.
Sign in to post your reply or Sign up for a free account.
Similar topics
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. ...
|
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
|
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...
|
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:...
|
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?
...
|
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
(...
|
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...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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,...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |