This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC 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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "resultset is not working properly" Watch "resultset is not working properly" New topic
Author

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

Thanks
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1786
    
  16

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
Greenhorn

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

Joined: Oct 23, 2005
Posts: 3712
    
    5

Have you tried this?


My Blog: Down Home Country Coding with Scott Selikoff
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
Bartender

Joined: Oct 14, 2005
Posts: 18712
    
    8

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: resultset is not working properly