Java SQL Exceptions question?

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();
LVL 3
seanmccullyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zzynxSoftware engineerCommented:
>> SELECT FLIGHTS FROM FLIGHTS
You can write SELECT * from FLIGHTS  (* stands for all columns) or you can give a column that does exist
0
zzynxSoftware engineerCommented:
>> SQL Exception: Table 'CL_SCHED' does not exi
Well, does that table CL_SCHED exist? Apparently not...
0
CodingExpertsCommented:
Well can you post the table structure ..
-CE
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

JavatmCommented:
> 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
JavatmCommented:
> 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
suprapto45Commented:
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
JK2429Commented:
If you can change the column name FLIGHTS, that will help you by getting rid of some errors and some confusion also.  :o)
0
seanmccullyAuthor Commented:
Alright the column Name does exist in the database as do both tables
0
seanmccullyAuthor Commented:
could it be a driver issue?
0
seanmccullyAuthor Commented:
would concurrent statements make a difference for error 1
0
zzynxSoftware engineerCommented:
>> 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
seanmccullyAuthor Commented:
here
SELECT * FROM PROJECT

SQL Exception: Table 'PROJECT' does not exist
same error
0
zzynxSoftware engineerCommented:
>> 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
zzynxSoftware engineerCommented:
First, let's focus on the 1st problem
0
zzynxSoftware engineerCommented:
>> I writing a java application for the Cloudscape database using two different databases
Sure you connect to the right database?
0
seanmccullyAuthor Commented:
yeah if I do SELECT * FROM FLIGHTS the query works fine
0
seanmccullyAuthor Commented:
noting that a query on an individual or multiple columnts for the table flights gives a sql error
0
zzynxSoftware engineerCommented:
Could you post some more code please?
0
seanmccullyAuthor Commented:
fixed the error thanks though
0
seanmccullyAuthor Commented:
what about this
SQL Exception: Column name 'COUNTRY' is in more than one table in the FROM list.
0
seanmccullyAuthor Commented:
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
CodingExpertsCommented:
> 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
seanmccullyAuthor Commented:
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
seanmccullyAuthor Commented:
Actually syntax error nevermind
0
seanmccullyAuthor Commented:
Statement.executeQuery() cannot be called with a statement that returns a row count.
should i use a prepared statement instead?
0
CodingExpertsCommented:
see this url for UPDATE Sql guide and check for your sql syntax

http://www.w3schools.com/sql/sql_update.asp
0
CodingExpertsCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.