?
Solved

Java SQL Exceptions question?

Posted on 2004-11-18
27
Medium Priority
?
173 Views
Last Modified: 2010-03-31
I writing a java application for the Cloudscape database using two different databases I get these errors noting that both FLIGHTS exists as a column in database 1 and that the table CL_SCHED exists as a table in database 2 the following strings are the queries that create these errors, I am using the derby cloudscape driver and not sure if its a driver issue something wrong with my sql statements or ..... Also noting that a full query on the FLIGHTS table returns a correct resultset of that table.

string 1 : SELECT FLIGHTS FROM FLIGHTS

string 2 : SELECT * FROM CL_SCHED


Database 1 : SQL Exception: Column 'FLIGHTS' is not in any table in the FROM list or it appears within a join specification and is outside the scope of the join specification or it appears in a HAVING clause and is not in the GROUP BY list.  If this is a CREATE or ALTER TABLE statement then 'FLIGHTS' is not a column in the target table.


Database 2 : SQL Exception: Table 'CL_SCHED' does not exist

stmt = conn.createStatement();
stmt.setAutoCommit(false);
rslSet = conn.executeQuery();
0
Comment
Question by:seanmccully
  • 12
  • 7
  • 4
  • +3
27 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 12622635
>> SELECT FLIGHTS FROM FLIGHTS
You can write SELECT * from FLIGHTS  (* stands for all columns) or you can give a column that does exist
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12622638
>> SQL Exception: Table 'CL_SCHED' does not exi
Well, does that table CL_SCHED exist? Apparently not...
0
 
LVL 6

Expert Comment

by:CodingExperts
ID: 12622731
Well can you post the table structure ..
-CE
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 15

Expert Comment

by:Javatm
ID: 12622799
> SELECT FLIGHTS FROM FLIGHTS

You can try what zzynx said, and add a WHERE to directly explicitly compare :
" SELECT * FROM FLIGHTS WHERE YourField = 'YourValue' ";


> SQL Exception: Table 'CL_SCHED' does not exist

If this is the case have you registered the driver to Data Sources(ODBC) from Administrative Tools of Control Panel ?
If your using windows as your OS be sure to register it 1st or if you dont want you can
call it directly by using a DNS-less Connection.

Here's a Demo :
http://www.experts-exchange.com/Q_20940877.html

Hope that helps . . .
Javatm
0
 
LVL 15

Expert Comment

by:Javatm
ID: 12622810
> SQL Exception: Table 'CL_SCHED' does not exist

Ohh I see sorry I thought it was a database ignore my 2nd comment. Just make sure that it exist or if it exit and the program cant find it.
Remove the _ undersign because that could add to the problem.
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 12624591
Dear seanmcully,

Yes, please send us all of your database structure.

For your first problem, the problem is on the field name. Check whether you have field with name of "FLIGHTS". For your second problem, the table may be in different name.

Dave
0
 
LVL 4

Expert Comment

by:JK2429
ID: 12625125
If you can change the column name FLIGHTS, that will help you by getting rid of some errors and some confusion also.  :o)
0
 
LVL 3

Author Comment

by:seanmccully
ID: 12626244
Alright the column Name does exist in the database as do both tables
0
 
LVL 3

Author Comment

by:seanmccully
ID: 12626252
could it be a driver issue?
0
 
LVL 3

Author Comment

by:seanmccully
ID: 12626277
would concurrent statements make a difference for error 1
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12626371
>> Alright the column Name does exist in the database as do both tables
Better not use the same name (FLIGHTS) for a column and a table
0
 
LVL 3

Author Comment

by:seanmccully
ID: 12626383
here
SELECT * FROM PROJECT

SQL Exception: Table 'PROJECT' does not exist
same error
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12626400
>> string 1 : SELECT FLIGHTS FROM FLIGHTS
What do you get if you try

        SELECT * FROM FLIGHTS     (or just another column)

Could you try that please?
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12626409
First, let's focus on the 1st problem
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12626430
>> I writing a java application for the Cloudscape database using two different databases
Sure you connect to the right database?
0
 
LVL 3

Author Comment

by:seanmccully
ID: 12626596
yeah if I do SELECT * FROM FLIGHTS the query works fine
0
 
LVL 3

Author Comment

by:seanmccully
ID: 12626601
noting that a query on an individual or multiple columnts for the table flights gives a sql error
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12626626
Could you post some more code please?
0
 
LVL 3

Author Comment

by:seanmccully
ID: 12628102
fixed the error thanks though
0
 
LVL 3

Author Comment

by:seanmccully
ID: 12628987
what about this
SQL Exception: Column name 'COUNTRY' is in more than one table in the FROM list.
0
 
LVL 3

Author Comment

by:seanmccully
ID: 12637025
Alright apparently the reson string 2 wasnt working because the Table schema had to be included in the SELECT clause like this SELECT * FROM  SAMP.CL_SCHED
0
 
LVL 6

Accepted Solution

by:
CodingExperts earned 1000 total points
ID: 12641280
> SQL Exception: Column name 'COUNTRY' is in more than one table in the FROM list.

You are using 2 tables  both of which contain the COUNTRY column is apparently the issue. You should use an alias for table names in that case.

ex

SELECT *
FROM FLIGHTS F, CL_SHED S
WHERE F.COUNTRY  = c.COUNTRY ;

-CE
0
 
LVL 3

Author Comment

by:seanmccully
ID: 12641651
Thanks that should help
and if somebody could help with this one as well that wouldbe great
SQL Exception: Syntax error: Encountered "FLYING_TIME" at line 1, column 24

UPDATE AIRLINES SET FLYING_TIME = VALUE WHERE FLIGHTID = VALUE
0
 
LVL 3

Author Comment

by:seanmccully
ID: 12641680
Actually syntax error nevermind
0
 
LVL 3

Author Comment

by:seanmccully
ID: 12641696
Statement.executeQuery() cannot be called with a statement that returns a row count.
should i use a prepared statement instead?
0
 
LVL 6

Expert Comment

by:CodingExperts
ID: 12641713
see this url for UPDATE Sql guide and check for your sql syntax

http://www.w3schools.com/sql/sql_update.asp
0
 
LVL 6

Expert Comment

by:CodingExperts
ID: 12641816
You can use ..


PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?");
pstmt.setBigDecimal(1, 153833.00);
pstmt.setInt(2, 110592);
ResultSet rs = pstmt.executeQuery() ;
int rowCount = 0;
while(rs.next())
{
  rowCount = rs.getInt("column name");
}

-CE
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month16 days, 10 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question