File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes resultset is not working properly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "resultset is not working properly" Watch "resultset is not working properly" New topic

resultset is not working properly

Rd Dari
Ranch Hand

Joined: Feb 22, 2010
Posts: 211

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

chris webster

Joined: Mar 01, 2009
Posts: 2289

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.

No more Blub for me, thank you, Vicar.
shiva pandey

Joined: Jan 24, 2011
Posts: 10
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

Joined: Feb 22, 2010
Posts: 211

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
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

Have you tried this?

[OCA 8 Book] [Blog]
Rd Dari
Ranch Hand

Joined: Feb 22, 2010
Posts: 211

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

Joined: Aug 05, 2009
Posts: 38
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

Joined: Oct 14, 2005
Posts: 19973

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.
I agree. Here's the link:
subject: resultset is not working properly
It's not a secret anymore!