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 8858
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: 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...
|
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"....
|
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 =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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...
|
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)...
| |