This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes no data found error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "no data found error" Watch "no data found error" New topic
Author

no data found error

Betsy Camel
Ranch Hand

Joined: Oct 02, 2003
Posts: 119
String values = "",data = "",Machineip = "";
List list = myclass.listing();
Iterator it = list.iterator();
String value = "";
while(it.hasNext())
{
value = it.next().toString();
%>
<td><%=value%></td>
<%
java.sql.ResultSet res = myclass.selectQuery();
while(res.next())
{
data = res.getString(value);
//if(value.equals("Machine_IP"))Machineip = res.getString(value);

}}

this code gives a no data found error...even though there is data ... can anyone help?
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
Maybe show us what listing and selectQuery is doing. Using ResultSet as you do is not good idea. Move your database work to some java class and all the logic do there and for jsp prepare just data to show.


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Betsy Camel
Ranch Hand

Joined: Oct 02, 2003
Posts: 119
I am having a table in which the column no can change. now i need to display all the values in the screen. which collection shud i use. plz its urgent
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
First create the bean which will hold the data from the table, than put beans in some collection (ArrayList for example) and iterate it on the jsp.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

which collection shud i use. plz its urgent


Betsy, JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

Please read this for more information.

thanks,
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Betsy Camel
Ranch Hand

Joined: Oct 02, 2003
Posts: 119
Sorry for using abbreviations but i am in need of knowing which collection will help me to access the data.
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
It depends on structure of data. Can you give some example about the data? But try to think about the bean as a holder of data please
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by David Ulicny:
But try to think about the bean as a holder of data please


Yes. A collection of your VOs (Value Objects). Value Object also known as Transfer Object.
Betsy Camel
Ranch Hand

Joined: Oct 02, 2003
Posts: 119
what if the values in the value objects changes ? for example if i try to alter the table by adding a column. the bean will have to incorporate a new getter/setter. how can this be incorporated ??
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Shouldn't the return from it.next() be cast to String?


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
Originally posted by Roger Chung-Wee:
Shouldn't the return from it.next() be cast to String?
Why? Object has a toString() method, so a cast would surely be unnecessary.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
I think a cast is necessary because the toString method for class Object might return something like this.

<classname>@111f71

So, when the variable value refers to a String like "<classname>@111f71", then it is no wonder that this line of code gives the wrong result.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
Originally posted by Roger Chung-Wee:
I think a cast is necessary because the toString method for class Object might return something like this.

<classname>@111f71[/CODE]
Have you tried it? Surely it will use runtime binding and invoke whichever toString() method that particular class has implemented? [That's what is called polymorphism.] If you haven't overridden the toString() method, well that's different.

:p
Srilakshmi Vara
Ranch Hand

Joined: Jul 21, 2004
Posts: 169
If you are not sure of number of columns, you cannot create a collection of objects becuase the object need to be changed every time a DB change occurs, instead you can store them as ArrayList of ArrayList. But this works only if you are not applying any logic to the data.

HTH
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
You know, it really helps when people can remember the basics of Java before making posts. I am ashamed to say that I was completely wrong.

it.next().toString(); will indeed return the String value.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
Everybody does that sort of thing . . . don't worry about it
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Originally posted by Roger Chung-Wee:
You know, it really helps when people can remember the basics of Java before making posts. I am ashamed to say that I was completely wrong.
But you learned something that you hadn't learned correctly before. It's a bonus when more than one person learns something from a thread.
Betsy Camel
Ranch Hand

Joined: Oct 02, 2003
Posts: 119
can anyone help me in my query please
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Betsy Camel:
can anyone help me in my query please


You need to make change in your code.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Break the problem into two parts. Firstly, what does this do when you run it?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: no data found error
 
Similar Threads
web application in eclipse 9
reading data from jsp page to another jsp page using request.getParameter
error showing while retrieving the data from drop down list
How to display records in Grid view format in Jsp
so close to having DB data put into bean, then into a table in a JSP