Jeetandra,

Include the following code in your program.

try {
       SQL code goes here...

       while (rs.next())  //Records returned
          {
            write the html here
          }
    }

catch (SQLException ex)
        {
          toClient.println("<html>");
          toClient.println("<title>IDP - Add Course</title>");
          toClient.println("*** SQL EXCEPTION in Servlet  ***");
          toClient.println("SQLState: " + ex.getSQLState());
          toClient.println("Message:  " + ex.getMessage());
          toClient.println("Vendor:   " + ex.getErrorCode());
          toClient.println("</html>");
        }       // end of Catch

There are a number of good books that show that you might want to look
at for more examples.

John


Jeetandra Mahtani wrote:
>
> Hello,
> I have a form in which the fields have to be
> populated with data from a table.
> <td width="33%">Company: <input type="text"
> name="C1COCO" size="3" maxlength="3" value=<%=
> rs.getString("C1COCO") %>> </td>
> where rs is of type ResultSet but I am getting the
> following error:
>
> d:\WEBSPH~1\APPSER~1\servlets\pagecompile\_complaintsys\_test3_xjsp.java:83:
> Exception java.sql.SQLException must be caught, or it
> must be declared in the throws clause of this method.
> out.print(ServletUtil.toString(
> rs.getString("C1COCO") ));
>                                             ^1 error
>
> Any suggestions/ideas?
> J
>
> _________________________________________________________
> DO YOU YAHOO!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to