Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Greenhorn
Posts: 20
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Posts: 20
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

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
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Posts: 20
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

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.

 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
praveen og,
Your post was moved to a new topic.
 
Don't touch me. And dont' touch this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
    Bookmark Topic Watch Topic
  • New Topic