aspose file tools*
The moose likes JDBC and the fly likes my query is successfully running in database but it is returning empty resultset in my java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

my query is successfully running in database but it is returning empty resultset in my java program

ripu sudan
Greenhorn

Joined: Dec 07, 2010
Posts: 20

String date="03-12-2010";

String query = "select TOTAL_SUBS, ACTIVE_SUBS,NEW_SUBSCRIPTION, ONE_WEEK_RENT,TWO_WEEK_RENT,THREE_WEEK_RENT,SUBSCRIPTION ,RBT_PURCHASE,RBT_GIFT,TOTAL_CALL_PULSE ,SMS , ((NEW_SUBSCRIPTION_AMOUNT+ONE_WEEK_AMOUNT+TWO_WEEK_AMOUNT+THREE_WEEK_AMOUNT+SUBSCRIPTION_AMOUNT+TOTAL_PULSE_AMOUNT+SMS_AMOUNT)/2+(RBT_PURCHASE_AMOUNT+RBT_GIFT_AMOUNT)/4)/USD_RATE as REVENUE from daily_invoice where invoice_date like '"+date+"%'";


java.sql.PreparedStatement pstmt = con.prepareStatement(query);

java.sql.ResultSet rs =null;

rs = pstmt.executeQuery(query);

while( rs.next() )
{

System.out.println("yeppie 111 have data");
}











========================================
hi every one i have following problem,
if i am running this query in database there is one entry corresponding to this query means it is running successfully
but when i am running this query with my java program i got "EMPTY RESULTSET".


means i am not able to get print string "yeppie 111 have data"



i have tried many solution please help me
thanks to all members in advance
Ed Ward
Ranch Hand

Joined: Jan 30, 2006
Posts: 147
Do you gt an error message at all?
Maybe try printing out the value of the "query" String reference just before you execute it in the program so you can see what is actually being executed. From time to time this is very enlightening for me.


BTW, this is probably better suited for the JDBC/SQL forum.
ripu sudan
Greenhorn

Joined: Dec 07, 2010
Posts: 20

Ed Ward wrote:Do you gt an error message at all?
Maybe try printing out the value of the "query" String reference just before you execute it in the program so you can see what is actually being executed. From time to time this is very enlightening for me.


BTW, this is probably better suited for the JDBC/SQL forum.








thanks for attention ,Ed ward

i also tried earlier by print my query before statement
as

System.out.println(query);
java.sql.PreparedStatement pstmt = con.prepareStatement(query);

and when i copy it and execute in database it is working fine
but in java program it is giving empty resultset.
Ed Ward
Ranch Hand

Joined: Jan 30, 2006
Posts: 147
Without actually seeing the query, one can only speculate.
The other thing I would check is to make sure your proggie is connecting to the correct database.
Sounds odd I know, but stranger things have happened.
You sure about that date format?
ripu sudan
Greenhorn

Joined: Dec 07, 2010
Posts: 20

Ed Ward wrote:Without actually seeing the query, one can only speculate.
The other thing I would check is to make sure your proggie is connecting to the correct database.
Sounds odd I know, but stranger things have happened.
You sure about that date format?






i also hard coded the date in query and than run in database it is working fine,
but not in my program.
and as far as connection is concern i am connected to correct database and also run other queries also they are running successfully.

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10255
    
    8

praveen og,
Your post was moved to a new topic.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
Consider Paul's rocket mass heater.
 
subject: my query is successfully running in database but it is returning empty resultset in my java program