• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

resultset is not working properly

 
Rd Dari
Ranch Hand
Posts: 212
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,


I have following code... what is the problem in this it is fetching value only second query




I have value in resident_ele_bill_ref but it is not taking that values...

please tell me what is the wrong in this code...

Thanks
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One general piece of advice: use bind variables for your query parameters. This is more secure and often more efficient than simply concatenating strings.

As for your queries, why don't you log into your database's SQL interface and run each query manually to see the results?

Once you have confirmed that your queries fetch the correct results, put them in your Java code and see what happens.
 
shiva pandey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rd Dari

In your first Sql Query the first field
society name
is right? check for space between society and name.
 
Rd Dari
Ranch Hand
Posts: 212
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shiva,

It is the right field its society_name in both of tables........
in actually these are the right queries both but its not showing value of second table .


I am selecting society name in a first page(search_electricity_bill.jsp) using AJAX and you can understand I am giving my all code and table below:---------


my queries is that if the second table (resident_elec_bill_ref)is not having the value according to the society_name then it should showing data from the apppartment table but its only showing data only appartment table .....

This is my first page that working properly to get the society name in a taxt field using AJAX....



and this is the second page which is main page.....



These are the tables ......

So please tell me what is the wrong in this.................

I am very confused I think nothing major problem in this but what is the little bit ?

Thanks for understanding my queries....

 
Scott Selikoff
author
Saloon Keeper
Posts: 4028
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried this?
 
Rd Dari
Ranch Hand
Posts: 212
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guy,

I used this code but the problem is same infact only one row is showing .......



servlet is here...



Please help me what is the main problem where....

i need it imidiately..
 
Bernhard Haeussermann
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if this will solve the problem, but you should call the close() method on a ResultSet object once you're done using it (and before you reassign it).
You may also have to close() the Statement/PreparedStatement.
You should definately close() the Connection object when you're done with it. It's always a good idea to call close() on the connection in the finally-block of a try-catch construct, so that the database Connection is closed even if an exception occurs in the code that uses the Connection.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main problem is that you have way too much code. There are lots of other serious problems, but the most serious problem is that you are
using a test environment which is far too complicated. You don't need a web application to test your database access; put that aside and write a
small Java application which does nothing but test your database code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic