"No data found" error for Resultset
Hi all,
I am using Tomcat 4.1 and MS Access as the database.
<SCRIPT language=JavaScript>
<!--
function go(loc)
{
window.location.href = loc;
}
</SCRIPT>
<HTML>
.
.
<TR onclick="go('checkitem.shtml?make=<%out.print(rs.getString(1));%>');">
.
.
</HTML>
when i write the code above (rs.getString(1)) then i get the desired result. but if i users.getString(2) instead ofrs.getString(1) then i get the following error:
exception
org.apache.jasper.JasperException: No data found
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service
root cause
javax.servlet.ServletException: No data found
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
at org.apache.jsp.inbox_jsp._jspService(inbox_jsp.java:287)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
Please help me out.
Thanks i advance.
Regards,
Amol
[1595 byte] By [
AMOL_SD1a] at [2007-10-2 20:23:56]

well here is the fully functional code for my table.
<TABLE style="BORDER-COLLAPSE: collapse" borderColor="#ff7d00" cellSpacing=0 cellPadding=3 border=1 width="80%">
<!--TABLE HEADER CODE-->
<TR style="CURSOR: help">
<%
if (rs.next())
{
for (iCount=1; iCount<=6; iCount++)
{%>
<TD onclick="SortOrder('<%out.print(rsmdResult.getColumnName(iCount));%>')" width="16.6%" background="inbox_files/toporangelt.gif">
<CENTER><B><%out.println(ChangeString.makeUpper(rsmdResult.getColumnName(iCount)));%></CENTER></B>
</TD><%
}
}%>
</TR>
<!--TABLE ROW DATA CODE-->
<%
while (rs.next())
{%>
<TR onmouseover="this.style.backgroundColor='#ffdc9b';" style="CURSOR: crosshair" onclick="go('checkitem.shtml?make=<%out.print(rs.getString(1));%>');" onmouseout="this.style.backgroundColor='';" height=23>
<%
for (iCount=1; iCount<=6; iCount++)
{%>
<TD><%out.println(rs.getString(iCount));%></TD><%
}
%></TR><%
}
In the TABLE ROW DATA CODE i'm facing this problem. As you can see the result set will be holding the data from different tables, I cannot spcify the column name.
It is difficult to see what could be wrong without all the code, howver, your error suggests there is no data in one of the fields you are trying to return.
Could you modifiy the code to only output the primary key and check the records that fail to ensure all data is present?
Also, you do realise that
if (rs.next())
moves the result set forward 1 record, so that
while (rs.next())
Is looking at the next record along.
If the while and if are to look at the same record you can use
rs.previous()
thanks a lot guys. finally i got the problem in java i suppose (oops ;-)). consider the following code
import java.sql.*;
class db
{
public static void main(String ar[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Benchmark","","infosys");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from users");
while(rs.next())
{
System.out.print(rs.getString(1) + "\t: " + rs.getString(2) + "\n");
//System.out.print(rs.getString(1) + "\t: " + rs.getString(2) + "\n");
}
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
This code work fine giving me the desired o/p.
but when you uncomment the comment, you will get the following error
amol: amolsd
java.sql.SQLException: No data found
so as for now my problem is resolved.