JDBC / ODBC problem

G

goli

Hi,
I posted a message about a problem in UNION query.
http://groups-beta.google.com/group...8?q=sql+union+in+java&rnum=1#310c36512df95818

I have some more information:
The issue is as follows:
Suppose I have query A (using INNER JOIN) - number of rows in result =
10
Suppose I have query B (using INNER JOIN) - number of rows in result =
7
Query C is UNION of A and B, and I expect 17 rows in the result.
But I get only *7* !!!

If I change DB so query A will have 9 rows, the UNION will give me also
9 results.

Is it an ODBC or JDBC problem ?
Is it the ResultSet class problem ?
Maybe I get the results wrong. I use "while resultSet.next() { .. }

Here are results in excel table:
A B C A - one less C - one less
174285826 174262785 174262785 174285834 174262785
174285834 174262801 174262801 174285835 174262801
174285835 174262817 174262817 174285836 174262817
174285836 174262833 174262833 174285837 174262833
174285837 174263935 174263935 174285838 174263935
174285838 174264578 174264578 174285839 174264578
174285839 174265346 174265346 174285840 174265346
174285840 174285847 174285826 174285841 174285834
174285841 174286035 174285834 174285843 174285835
174285843 174285835 174285844 174285836
174285844 174285836 174285845 174285837
174285845 174285837

Thanks for any help.
 
A

AlexKay

goli said:
Hi,
I posted a message about a problem in UNION query.
http://groups-beta.google.com/group...8?q=sql+union+in+java&rnum=1#310c36512df95818
(snip)

Is it an ODBC or JDBC problem ?
Is it the ResultSet class problem ?
Maybe I get the results wrong. I use "while resultSet.next() { .. }

Sorry I don't have time to dig into your code but I would not be
surprised if you find bugs in databases, JDBC or ODBC drivers. Actually
I would be surprised if you didn't find any ;-|

I'll presume your code is correct and there is a bug beyond your direct
control, often the only recourse is to find a work around or
alternative. Do the query differently.

I'm using Oracle and one of its JDBC drivers and I find plenty of
problems. Today I need to code a query with MINUS, my confidence that
it'll actually work is pretty low. I'm automatically thinking of
alternatives.

Cheers,
Alex
 
C

christopher

I usually sys.out my sql queries (because I build them on the fly),
then cut and paste them in the MySQL front end in a telnet window. I
have found the darndest mistakes that way.

luck
 
A

AlexKay

I usually sys.out my sql queries (because I build them on the fly),
then cut and paste them in the MySQL front end in a telnet window. I
have found the darndest mistakes that way.

luck

Hey yeah,

I do that too, goli I take back my original assumption that you code
has no bugs .. maybe it does?

I agree with christopher here, you should really check your SQL as
well, maybe you'll find a bug in your sql statement after all? .. it
does happen to the best of us ... ;-)

Cheers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top