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 getting empty resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "getting empty resultset" Watch "getting empty resultset" New topic
Author

getting empty resultset

Hd Desai
Ranch Hand

Joined: Aug 04, 2003
Posts: 65
Hi,
I am using Sybase and Java 1.4. The program is executing stored procedure which returns resultset.

Now when I try to execute the stored proc from RapidSQL it is returning me result, but when executed from Java program it gives empty resultset.

It is not giving any exception or error. I tried checking resultset size in Java and it is returning zero.Here is the code snippet,

m_objCallableStmt = p_objConn.prepareCall(P_GET_PRC_CHG_RPT);
m_objCallableStmt.setDate(1, dbDate);
m_objCallableStmt.setDouble(2, m_dblThrhdVal);

m_objRS = m_objCallableStmt.executeQuery();

int cnt =0;
while(m_objRS.next()){
cnt++;
}
log.debug("Cont of resultset is :"+cnt);

Please let me know what is causing this issue here.

Thanks in advance.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

The answer isn't complicated: your query doesn't return any records.

If you want to know why not, you would have to examine the query and the parameters you passed to it. (Neither of which we can see.)
Hd Desai
Ranch Hand

Joined: Aug 04, 2003
Posts: 65
Hi Paul,

Thank you for replying.

As mentioned I am execuuting stored procedure and parameters are 2012-03-06 and 0.12 respectively.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Okay. So your problem is solved, then. Would you like me to mark it as "Resolved"?
Hd Desai
Ranch Hand

Joined: Aug 04, 2003
Posts: 65
I wish it had :-(

It is still unsolved ,I said thank you because you gave some time to read and reply. But unfortunately it is not solved yet.
Ram Narayan.M
Ranch Hand

Joined: Jul 11, 2010
Posts: 247

If your Stored Procedure returns more than one ResultSet (i.e, if Stored Procedure contain more than one "select" query statements), use execute() method.


SCJP 6 [SCJP - Old is Gold]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Hd Desai wrote:It is still unsolved ,I said thank you because you gave some time to read and reply. But unfortunately it is not solved yet.


May I ask why you posted this problem here?

Normally when people post their problems on these forums, it's because they want other people to help them solve those problems. But you don't appear to want any help. Or at least if you do, you certainly aren't acting like it.
Hd Desai
Ranch Hand

Joined: Aug 04, 2003
Posts: 65
Paul, please dont read my post if you are not interested in.I know why I am here and what is problem.

There are people who are interested in help people, I can better ask them.

@Ram : My stored procedure is having only 1 select with multiple joins. And i verified it is not returning multiple resultsets.
Ram Narayan.M
Ranch Hand

Joined: Jul 11, 2010
Posts: 247

Try changing the Sybase JDBC Driver if you are referring to upgraded Sybase DB version with very old Sybase JDBC Driver.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Hd Desai wrote:There are people who are interested in help people, I can better ask them.


I'm suggesting that you could do it more effectively than you are doing it now. I already suggested that looking at the query would be an important part of solving the problem. To be more clear, I'm suggesting that you should post the query here so that people could look at it.
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

Why don't you take out the query from the stored procedure, plug in the 2 argument values ("hard code" them in the query) and run it manually to see if it returns anything. That's where I would start.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting empty resultset