Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why resultSet is null?

 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure query is getting executed ???

Shailesh
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In API is written never null. If there is no exception, than it could be a bug in DB2 implementation.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Shailesh, i am printing resultSet just after getting it. It is showing me null.

No Exception even.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interesting ??

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

Shailesh
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shailesh Chandra:
could you please put the code ...might be something triggers ?




Method fsexecuteQuery(String query)

 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bah, do not get me started about legacy code. You do not want to get me started! Glad it's solved though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic