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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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

 
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
 
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.

 
Bartender
Posts: 11445
18
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
Boost this thread!