File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Strange problem: JDBC: Oracle Connection: Cursor hangs in ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Strange problem: JDBC: Oracle Connection: Cursor hangs in ResultSet" Watch "Strange problem: JDBC: Oracle Connection: Cursor hangs in ResultSet" New topic
Author

Strange problem: JDBC: Oracle Connection: Cursor hangs in ResultSet

Charles Foetz
Greenhorn

Joined: Nov 22, 2004
Posts: 3
Hi,

My program connects to an oracle db and queries all records (480'000) from a table with 4 columns (of which one, Z00_DATA, is of type LONG (and on average is about 1000 chars long)).

From my Windows machine, the program runs fine.

From a linux box the same program doesn't: it executes the statement, but when I skim through the returned resultset (even if I only count the number of records in it, it gets stuck on record 80. No exception thrown (I'm catching a general Exception object), it just hangs.

[[ while (rs.next) { counter++; System.out.println(counter);} ]]

When I change my query slightly and select only 3 columns (all except the LONG one), it runs fine again.

This seems very odd to me since I'm not even reading the data inside the resultSet. (I will later, I'm just debugging now).

Here's the code, if anyone can, please help.

Charlie

-------------------



[edited to add code tags]
[ November 22, 2004: Message edited by: Jeanne Boyarsky ]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30515
    
150

Charles,
Welcome to JavaRanch!

I'm not sure why it is hanging at that point. It wouldn't matter if you are accessing the columns though. JDBC has to transfer to whole row to your machine, even if you ignore it. That's why it is recommended to only select the columns you are going to use. (I'll assume you are going to use all the columns later though.)

Is there any other database activity going on while you try this? Maybe someone has a lock on part of the result?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Charles Foetz
Greenhorn

Joined: Nov 22, 2004
Posts: 3
Thanks for your reply, Jeanne.

Yes I need all the columns. There is probably some access to the database, much rather than changing the rows I'm getting stuck on, new rows are being added. For a given query it always hangs at the same row,

i.e. normally record 80 / 480.000

If I query all records where recordID isn't 80, it gets stuck at 79.
If I query all records where recordID > 100, it goes up to something like 160.

The data in the row that makes it get stuck is nothing too different from data in other rows. I suspect something to do with a full heap or buffer, Java internally.

What I really don't get is that it runs fine on my windows machine, but not on the Linux one. Other queries (on other tables) run fine on both machines. Only for this very table the problem occurs, and only if the query includes this Z00_DATA column, of type LONG. And how can it just hang, rather than giving me an exception?

Charlie
Charles Foetz
Greenhorn

Joined: Nov 22, 2004
Posts: 3
I tried using the oci driver instead of thin, also tried using older oracle classes (classes12 and classes111 instead of ojdbc14), doesn't change a thing :-(
Charlie
 
wood burning stoves
 
subject: Strange problem: JDBC: Oracle Connection: Cursor hangs in ResultSet