aspose file tools*
The moose likes JDBC and the fly likes ResultSet is null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ResultSet is null" Watch "ResultSet is null" New topic
Author

ResultSet is null

Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
I'm using db2jcc driver to connect with DB2. It is giving me a null ResultSet object. It shouldn't be like that. Execution never returns null as ResultSet object. Below is my code.




Javadocs says:

public ResultSet executeQuery() throws SQLException

Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.

Returns:
a ResultSet object that contains the data produced by the query; never null
Throws:
SQLException - if a database access error occurs or the SQL statement does not return a ResultSet object


Any inputs??
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Which driver are you using? An incorrect implementation could be to blame.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by David O'Meara:
Which driver are you using? An incorrect implementation could be to blame.


Its type 4.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31057
    
232

Adeel,
I think Dave meant more specifics about the driver. What company made it? What is it called?

I definitely agree with him that it is a problem in the driver. You are both correct that executeQuery() never returns null.


[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
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Jeanne Boyarsky:
I think Dave meant more specifics about the driver. What company made it? What is it called?


Hi Jeanne.

Dont know much about the driver. Infact I haven't downloaded this myself. This is given by one of my work place colleague. The file called db2jcc.jar and I am using type 4 driver. I have tried to get more information by seeing its properties. WindowsXP is showing me nothing, but the date modified, created, etc.

Packages are like below.

- com.ibm.db2.jcc.sqlj
- com.ibm.db2.jcc.uw
- com.ibm.db2.jcc.t2
- com.ibm.db2.jcc.resources
- com.ibm.db2.jcc.a
- com.ibm.db2.jcc.b
- com.ibm.db2.jcc.c

Please notice last three packages I have mentioned above. What kind of name is this? It has class files like

a.class
b.class
c.class
.
.
.
z.class

After using all the english alphabets, the name are the combinations of alphabets like

bu.class
bc.class
bt.class

Its not following the naming conventions even. The class name should be with initCap.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

My feeling is that there is some other error going on other than the null pointer and the null pointer is masking the real problem. Do you know if the query generated works? I'd try moving things into isolation and run simpler queries like "select * from ..." until you've worked out the kinks.


My Blog: Down Home Country Coding with Scott Selikoff
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31057
    
232

Adeel,
The standard db2 driver is db2java.zip. Does your query work with that driver?
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Jeanne Boyarsky:
The standard db2 driver is db2java.zip. Does your query work with that driver?


Yes. But as far as I know we need to install the DB2 Client in order to use db2java.zip. Even I install the client prior to use that driver. What you say?
[ November 21, 2005: Message edited by: Adeel Ansari ]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Scott Selikoff:
My feeling is that there is some other error going on other than the null pointer and the null pointer is masking the real problem. Do you know if the query generated works? I'd try moving things into isolation and run simpler queries like "select * from ..." until you've worked out the kinks.


I have tried all the stuff. But the problem is in the driver. Sometimes it gives null as a result of a query. And sometimes it fetches the record fine for against the same query. And sometimes it says no record found, although there are some records in there.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
sometime working, sometimes not.
smells like a threading problem, either in your code or within the driver implementation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ResultSet is null