JSP problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • simba
    New Member
    • Jan 2007
    • 9

    JSP problems

    Hi I'm having problems displaying information that I am retrieving from a database through an sql query.

    My jsp code is as follows:

    <%@ page language="java" contentType="te xt/html" errorPage="erro rpage.jsp" import="java.sq l.*, java.util.*" %>
    <jsp:useBean id="connect" class="myBeans. HostelConnectBe an" />
    <jsp:setPropert y name="connect" property="*" />

    <html><head><ti tle>Login</title></head>
    <body>
    These are the hostels: <%= connect.selectH ostel() %>

    </body></html>

    But the output from this is:

    These are the hostels: oracle.jdbc.dri ver.OracleResul tSet@e134e6 instead of displaying the hostels.

    Can anyone shed any light on why this is happening?

    Thanks
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    I think ur connect.selectH ostel() returns the the instance of Resultset interface.
    That's why the result is obtained from the toString() method.........
    connect.selectH ostel().toStrin g() that means the third party implemented class name is oracle.jdbc.dri ver.OracleResul tSet.........
    oracle.jdbc.dri ver.OracleResul tSet.toString() method is called...
    Such format generally from the toString() method ...XXXX@XXXX

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by dmjpro
      I think ur connect.selectH ostel() returns the the instance of Resultset interface.
      That's why the result is obtained from the toString() method.........
      connect.selectH ostel().toStrin g() that means the third party implemented class name is oracle.jdbc.dri ver.OracleResul tSet.........
      oracle.jdbc.dri ver.OracleResul tSet.toString() method is called...
      Such format generally from the toString() method ...XXXX@XXXX

      It does. The OP should now extract the relevant data from the resultset for display.

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        How the ResultSet istance is used to retrive data.........

        <%ResultSet l_result = connect.selectH ostel();

        while(l_result. next())
        {%>
        <html_tag><%=l_ result.getStrin g("COLUMN_NAME" )%></html_tag>
        <%}
        %>

        I think think hostel name is character basis....
        And ur query is somthing like this...
        select HOSTEL_NAME from HOSTEL_DATABASE

        Comment

        Working...