Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Location
    india
    Posts
    1

    Unanswered: tomcat 5, oracle 8i, jsp

    Hi everyone first time posting query to a forum, thanks in advance for everyone giving it a look.

    my problem is:
    i have a jsp page in which i have some method defined which gets database Connection from a another method defined in the same jsp page.
    i am trying to make a search page, it works with single call to one method but if one particular method is called more than once i get ResultSet Exhausted error. i am closing all ResultSet, Statements, and Connection.
    Error Trace is:
    javax.servlet.ServletException: Exhausted Resultset
    org.apache.jasper.runtime.PageContextImpl.doHandle PageException(PageContextImpl.java:867)
    org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:800)
    org.apache.jsp.test1_jsp._jspService(test1_jsp.jav a:271)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:133)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:311)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)


    root cause

    java.sql.SQLException: Exhausted Resultset
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java)
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java)
    oracle.jdbc.driver.OracleStatement.prepare_for_new _get(OracleStatement.java)
    oracle.jdbc.driver.OracleStatement.getStringValue( OracleStatement.java)
    oracle.jdbc.driver.OracleResultSetImpl.getString(O racleResultSetImpl.java)
    org.apache.commons.dbcp.DelegatingResultSet.getStr ing(DelegatingResultSet.java:198)
    org.apache.jsp.test1_jsp.searchSpecialityTable(tes t1_jsp.java:57)
    org.apache.jsp.test1_jsp._jspService(test1_jsp.jav a:218)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:133)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:311)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)

  2. #2
    Join Date
    Nov 2003
    Location
    Bangalore,India
    Posts
    51

    Re: tomcat 5, oracle 8i, jsp

    1.Seems there is casting problem. Are you using Numeric where it is expecting string parameters......
    2. Try closing the connection within loop
    Cheers
    Keep things simple as world is already complex

  3. #3
    Join Date
    Apr 2006
    Posts
    1

    Question

    Hi there,,,

    i still have the same problem and here i will paste my code

    so please can any one correct my mistake or send it to

    prog207@hotmail.com
    ===================================
    <%@ page import="sun.net.smtp.SmtpClient, java.io.*"%>
    <HTML>
    <BODY>
    <%@ page import = "java.sql.*"%>
    <%! Connection conn = null;
    try {
    // Load the JDBC driver
    String driverName = "oracle.jdbc.driver.OracleDriver";
    Class.forName(driverName);

    // Create a connection to the database
    String serverName = "myserver";
    String portNumber = "1521";
    String sid = "TEST";
    String url = "jdbcracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
    String username = "myuser";
    String password = "mypw";
    conn = DriverManager.getConnection(url, username, password);
    } catch (ClassNotFoundException e) {
    // Could not find the database driver
    } catch (SQLException e) {
    // Could not connect to the database
    }
    %>
    <%
    // Get username.
    String email = request.getParameter( "email" );
    String USR = request.getParameter( "username" );
    String USER = "s" + USR;
    //if ( email == null || email == "" ) {
    %>
    <!--Please enter an email address............... -->
    <%
    // } else {
    try{
    Statement stmt = conn.createStatement();
    String sql = "SELECT PASSWORD FROM USERS WHERE USERNAME ='" + USR + "'";
    ResultSet rs = stmt.executeQuery(sql);
    rs.next();
    String PW = rs.getString(1);
    rs.close();
    stmt.close();
    conn.close();
    }catch (SQLException e) {
    System.out.println("Error: " + e.getMessage());
    }
    String from="mymail@mysmtp";
    try{
    SmtpClient client = new SmtpClient("mysmtp");
    client.from(from);
    client.to(email);
    PrintStream message = client.startMessage();
    message.println("To: " + email);
    message.println("Subject: Your Password");
    message.println("Congratulation");
    message.println();
    message.println(USER + " password is " + PW);
    message.println();
    message.println();
    client.closeServer();

    }
    catch (IOException e){
    System.out.println("ERROR SENDING EMAIL:"+e);
    }
    %>
    Thank you for requesting your password.<br>
    Password for the following ID <%= USR %> <br>
    Requested at at <%= new java.util.Date() %> <br>
    An email has been sent to <%= email %>
    <%
    //}
    //conn.close();
    %>
    </BODY>
    </HTML>
    ==============================================
    best regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •