This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

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

 
ripu sudan
Greenhorn
Posts: 20
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
 
Ed Ward
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • 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
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.

 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
praveen og,
Your post was moved to a new topic.
 
    Bookmark Topic Watch Topic
  • New Topic