Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 927829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:54:52+00:00 2026-05-15T19:54:52+00:00

I am a programmer, new to jsp, trying to write some code. i have

  • 0

I am a programmer, new to jsp, trying to write some code.

i have written like

    <%
            int i=1;

    String connectionURL = "jdbc:mysql://localhost:3306/registration";

     Connection connection = null;
        Statement stmt = null;
        ResultSet rset = null;
        Statement stmt1 = null;
        ResultSet rset1 = null;
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    int updateQuery = 0;
    try {
    connection = DBUtil.createConnection();//DriverManager.getConnection(connectionURL, "root", "root");
    String queryString = "select * from course";
    System.out.println("select all from course table");
     stmt = connection.createStatement();
    System.out.println("Statment object "+ stmt );
    rset = stmt.executeQuery(queryString);
    System.out.println("Result set " + rset );
    while (rset.next()) {
                    System.out.println("  Results...");
                    String s1 = rset.getString(1);
                    Double amount = rset.getDouble("amount");
                    String loginid = rset.getString("loginid");

    String queryString1 = "select * from users where loginid = '"+ loginid +"'";
    System.out.println("select user details from users table");
    System.out.println(queryString1);
     stmt1 = connection.createStatement();
    System.out.println("Statment object "+ stmt1 );
    rset1 = stmt1.executeQuery(queryString1);
    System.out.println("Result set " + rset1 );

             System.out.println("      name -> " + rset1.getString(2));
     %>
        <tr class="subtext1">
<td align="left"><%=i%> </td>
<td align="left"><%=rset.getString("name")%></td>
<td align="left"><%=rset.getString("loginid")%></td>
<td align="left"><%=rset.getString("name")%></td>
<td align="left"><%=rset.getString("email")%></td>
<td align="left"><%=rset.getString("iimbtrack")%></td>
<td align="left"><%=rset.getString("result")%></td>
<td align="left">CourseFee/<%=rset.getString("product")%></td>
<td align="left"><%=amount%></td>
<td align="left"><%=rset.getString("fdate")%></td>
</tr>

When I try to print this, it gives error. But when I remove this line:

System.out.println("      name -> " + rset1.getString(2));

It works. Where am I going wrong?

This is the error I get

statment object com.mysql.jdbc.Statement@429be9
Result set com.mysql.jdbc.ResultSet@10a0d51
java.sql.SQLException: Before start of result set
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
        at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:703)
        at com.mysql.jdbc.ResultSet.getStringInternal(ResultSet.java:5653)
        at com.mysql.jdbc.ResultSet.getString(ResultSet.java:5597)
        at org.apache.jsp.WEB_002dINF.jsp.secure.transaction.feesreports_jsp._jspService(feesreports_jsp.java:235)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:461)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:399)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
        at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
        at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:261)
        at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
        at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:316)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1158)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:54:53+00:00Added an answer on May 15, 2026 at 7:54 pm

    You need to call ResultSet#next() to move the cursor to the next row, otherwise you cannot access any data from the row. If you expect multiple rows, do this in a while loop:

    while (rset1.next()) {
        System.out.println(" name -> " + rset1.getString(2));
    }
    

    Or if you expect only one row, then do this in an if statement:

    if (rset1.next()) {
        System.out.println(" name -> " + rset1.getString(2));
    }
    

    See also:

    • JDBC tutorial
    • How to iterate through a ResultSet

    That said, this code is honestly said not the right way to achieve the functional requirement of displaying the data from a DB in a HTML table. This database interaction task shouldn’t be done inside a JSP file, but in a real Java class. The JSP page should be kept scriptlet-free.

    See also:

    • How to avoid Java code in JSP files
    • How to display data from database in a HTML table in JSP page
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New programmer here, I am trying to understand and break down this code below
I am new programmer in Obj-C and cocoa . Im a trying to write
I am a new programmer in Python and I am trying to do some
New Programmer here. Trying space invaders. I have a 2 dimensional array of objects
New programmer here with only some minor Java experience trying my hand at writing
I am a very new programmer, and I have some trouble with the examples
I am a very new programmer, I have made a couple basic applications, however
relatively new programmer here. Look at the two classes defined below. I'd like to
I am an experienced C++ programmer but new to Java. I have an algorithm
I am a new programmer... i have following problem.. Terminating app due to uncaught

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.