aspose file tools*
The moose likes JDBC and the fly likes Why resultSet is null? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Why resultSet is null?" Watch "Why resultSet is null?" New topic
Author

Why resultSet is null?

Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
I am using "com.ibm.db2.jcc.DB2Driver" to connect to DB2 Server.
After executing a query I'm getting null as a resultSet. The query should return 0 records. I have checked it via a database client Aqua Data Studio.

As far as I know that resultSet shouldn't be null, anyway. Am I right??
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Are you sure query is getting executed ???

Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
In API is written never null. If there is no exception, than it could be a bug in DB2 implementation.


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Yes Shailesh, i am printing resultSet just after getting it. It is showing me null.

No Exception even.
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

interesting ??

could you please put the code ...might be something triggers ?

Shailesh
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by David Ulicny:
In API is written never null. If there is no exception, than it could be a bug in DB2 implementation.


Yeah I know. Now I'm going to sue IBM for this silly implementation. It took my half an hour.

[edited]
No just kiddin. It took me less then 5 mins
[ September 19, 2005: Message edited by: Adeel Ansari ]
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by Adeel Ansari:
Now I'm going to sue IBM for this silly implementation. It took my half an hour.



Give them some time to fix this implementation

I don't think it would first time when the query is returning zero result, none has reported same problem.

such problem may occur if it is beta release or first release of driver.


Shailesh
[ September 19, 2005: Message edited by: Shailesh Chandra ]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Shailesh Chandra:
could you please put the code ...might be something triggers ?




Method fsexecuteQuery(String query)

Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Its Ok guys now its working like charm. I promise I didn't do a thing to it. I just closed the project and opened it again.

Anyways thanks mates.
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

1. Did you put System.out.println before executing query.......... ???

2. What is behaviour if everything goes well, when there are records available in database on given criteria.

3. your catch block in method fsexecuteQuery is not throwing exception out ??

Might be you didn't refresh log file to check error message and some exception occured


Shailesh
[ September 19, 2005: Message edited by: Shailesh Chandra ]
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by Adeel Ansari:
Its Ok guys now its working like charm


Cheers


I just closed the project and opened it again


might be old class was loaded during your test


Shailesh
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

ResultSets cannot be null when executed by the database, except when they are wrapped in a method as above where any failure in the method fsexecuteQuery will return a null ResultSet.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by David O'Meara:
ResultSets cannot be null when executed by the database


Know that quite well.


except when they are wrapped in a method as above where any failure in the method fsexecuteQuery will return a null ResultSet.



Cent percent valid point.

It was my carelessness. I didn't tried hard to figure it out. Legacy code screws most of the time.

Actually it was faced by one of my colleague and I posted the question. When Shailesh asked for code, then I realized that mistake is somewhere inside that method.

Thanks David.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Bah, do not get me started about legacy code. You do not want to get me started! Glad it's solved though.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why resultSet is null?