tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Helmling ...@panix.com>
Subject Re: Having a Newbie Delamere here.
Date Thu, 30 May 2002 12:26:27 GMT
In some of your code sections, you're trying to accessing values before
advancing the ResultSet to the first row.  For example, you have:

  stmt = conn.createStatement();
  rs = stmt.executeQuery(sQuery);

  // Assign values from the database
  sSubTitle = rs.getString("SubTitle");
  sFormName = rs.getString("FormName");
  sContent = rs.getString("Content");

try wrapping this in a call to rs.next():

  if (rs.next())
  {
    // Assign values from the database
    sSubTitle = rs.getString("SubTitle");
    sFormName = rs.getString("FormName");
    sContent = rs.getString("Content");
  }

Also, it's usually better to package this kind of functionality in a
JavaBean, which you can then instantiate and use in your JSP.  This
leaves your JSP code much cleaner and more readable, and allows you to
do more advanced things like caching values between identical requests
(like page refreshes).

--g

On Thu, 2002-05-30 at 03:21, Nicholas Orr wrote:
> Again coming from the ASP world of doing things.
> in ASP you can open a connection to a Database (DB) and execute a bunch of
> queries and do whatever you need to then after you have finished close the
> connection.
> 
> Now I have tried to do this in jsp, but not having much luck.  Keep getting
> 'Result set type is TYPE_FORWARD_ONLY'
> 
> Cause In ASP when you start a new ResultSet, after you have closed the
> previous one, (asp equiv = recordset) It automatically goes back to the
> begining as it should, but in jsp it seems to just hang around at rs.last().
> 
> !I don't know!
> 
> Well if you could help, I would appreciate it, Source included.
> 
> Regards,
> 
> Nicholas
> 
> 
> 
> 
> **********************************************************************
> The information contained in this e-mail is confidential and is
> intended only for the use of the addressee(s).
> If you receive this e-mail in error, any use, distribution or
> copying of this e-mail is not permitted. You are requested to
> forward unwanted e-mail and address any problems to the
> MIM Holdings Limited Support Centre.
> 
> For general enquires:	++61 7 3833 8000
> Support Centre e-mail:	supportcentre@mim.com.au
> Support Centre phone:  	Australia 1800500646
>         				International ++61 7 38338042
> **********************************************************************
> 
> ----
> 

> --
> To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message