Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

java.sql.SQLException: Before start of resultset

800304May 27 2008 — edited May 28 2008
Hi,
I am following the following steps:
1. Create the jsp CustDetLcl1.jsp which get the locality input from the supervisor.
2. The CustDetLcl1.jsp transfers the control to CustDetLcl.java which pulls the records of all the customers lying in the locality and forwards the control to CustDetLcl2.jsp
3. The records are displayed on CustDetLcl2.jsp

I am getting the following error message when CustDet.Lcl.java runs:
java.sql.SQLException: Before start of resultset
It is not displaying the records of all the customers that belog to that locality. Pls help.

The code for CustDetLcl.java is as follows:
package supervisor.locality;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.io.*;
import com.database.*;
import supervisor.locality.LocalityBean;
public class CustDetLcl extends HttpServlet 
{
public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
HttpSession session = request.getSession();
try
{
String X = request.getParameter("locality");
System.out.println(X);
Database db = new Database();
Connection con = db.useConnection();
String query = "select c.custname,c.address,c.locality,c.custid,c.amtoutstanding,c.interest,c.totalamtdue,a.fieldexecname from custinfo c, assignlcl a where c.fieldexeccode=a.fieldexeccode and c.locality=?";
PreparedStatement stat = con.prepareStatement(query);
System.out.println(stat);
stat.setString(1,X);
ResultSet rs = stat.executeQuery();
int count = 0;
String A[] = new String[1000];
String B[] = new String[1000];
String C[] = new String[1000];
String D[] = new String[1000];
String E[] = new String[1000];
String F[] = new String[1000];
String G[] = new String[1000];
String H[] = new String[1000];
for(int i=0;i<1000;i++)
{
A[i] = rs.getString("custname");
B[i] = rs.getString("address");
C[i] = rs.getString("locality");
D[i] = rs.getString("custid");
E[i] = rs.getString("amtoutstanding");
F[i] = rs.getString("interest");
G[i] = rs.getString( "totalamtdue");
H[i] = rs.getString("fieldexecname");
		
LocalityBean cb = (LocalityBean)session.getAttribute("cb");
if(cb==null)
{
cb = new LocalityBean(A, B[i], C[i], D[i], E[i], F[i], G[i],H[i]);
session.setAttribute("cb", cb);
}
System.out.println("custname" + A + "address" + B + "locality" + C + "custid" + D + "amtoutstanding" + E + "interest" + F + "totalamtdue" + G + "fieldexecname" + null );
RequestDispatcher dis = request.getRequestDispatcher("/CustDetLcl2.jsp");
System.out.println("Dispatched" + dis);
dis.forward(request, response);
}
}
catch(Exception e)
{
System.out.println(e);
e.printStackTrace();
}
}
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 25 2008
Added on May 27 2008
5 comments
290 views