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

  • Home
  • SEARCH
  • 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 7632439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:37:33+00:00 2026-05-31T06:37:33+00:00

I have this code: public class cuemath extends HttpServlet{ /** * */ private static

  • 0

I have this code:

    public class cuemath extends HttpServlet{
   /**
    *
    */
   private static final long serialVersionUID = 1L;
   String Q;
   String DOWNLOAD="";

   ArrayList<String> _DOWNLOAD_ ;



   public void doGet (HttpServletRequest req,
                   HttpServletResponse res)
   throws ServletException, IOException
   {
     PrintWriter out = res.getWriter();

   try{Connection myCon;


   _DOWNLOAD_ =new ArrayList<String>();



   Statement myStmt;

   String userName = "xxxx";
   String password = "xxxxxxxx";
   String url= "jdbc:mysql://localhost:3306/maths?user="
   +userName
   +"&password="
   +password;

   Class.forName ("com.mysql.jdbc.Driver").newInstance ();



   myCon = DriverManager.getConnection (url);


   myStmt = myCon.createStatement();
   ResultSet rs;

   String pm=req.getParameter("LessonId").trim();
   int p=Integer.parseInt(pm);

   String query="select * from lessons where LESSONS_ID="+p;
   rs= myStmt.executeQuery(query);

   out.println("<CUEMATH>");
   out.println("<lessonid>");


           out.println(rs.getString("LESSONS_ID"));

   out.println("</lessonid>");

   out.println("<lessontext>");

           out.println(replaceTags(rs.getString("LESSONS_TEXT")));

   out.println("</lessontext>");
   out.println("</CUEMATH>");

   }
   catch (Exception e) {
        e.printStackTrace();
}
   }
    private  String replaceTags(String Input){

           if(!Input.equals(null)){

                   String one =">";
                   String two ="<";
                   String five ="\n";
                   String seven ="\\t";

                   String three ="&gt;";
                   String four ="&lt;";
                   String six = "backslash";
                   String eight="tabspace";


                   Input = Input.replaceAll(one, three);
                   Input = Input.replaceAll(two, four);
                   Input = Input.replaceAll(five, six);
                   Input = Input.replaceAll(seven, eight);



                   Input=Input.replaceAll(five, six);
                   Input = Input.replaceAll(one, three);
                   Input = Input.replaceAll(two, four);


                   Input=Input.replaceAll(five, six);
                   return Input;


           }
           else
                   return "";


   }

}

I am getting this error log:

               java.sql.SQLException
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:815)
at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5528)
at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5448)
at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5488)
at cue.math.cuemath.doGet(cuemath.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:189)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:91)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:92)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:325)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)

I am generating a xml from database values.
I am newbie can anyone help me with this problem?

  • 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-31T06:37:34+00:00Added an answer on May 31, 2026 at 6:37 am

    Before you start retrieving results from the ResultSet object, you should add a call to rs.next()
    This call returns a boolean to indicate if a further row is available (in this instance, the first row), and moves the internal result set pointer to the next row of results (in this case the first row).

    Often, you will see this in code:

    if (rs.next())
    {
      // retrieve results from rs object
    }
    

    or for multiple rows

    while (rs.next())
    {
      // each iteration through this loop
      // is a separate result row...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code fragment: public static class ExportDatabaseFileTask extends AsyncTask<String, Void, Boolean> {
I have written this piece of code public class Test{ public static void main(String[]
I have this code: public class VoiceActivity extends Activity implements OnClickListener { private TextView
I have this piece of code : public class Profile extends Container{ public Profile(String
I have this code: public class Window extends JFrame { public Window(){ ... JButton
I have this code that describes a service: public class navigation_web extends Service {
I have this code for my soundboard, public class soundboardActivity extends Activity { View
I have class where I draw image. This is code: public class CanvasdrawActivity extends
Okay, so i have this code i wrote: class Connection { public static StreamWriter
I'm a beginner in Android. Here I have this code: public class GPS extends

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.