Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: JSP & Oracle

Re: JSP & Oracle

From: Sybrand Bakker <oradba_at_sybrandb.demon.nl>
Date: 20 Feb 2001 04:15:56 -0800
Message-ID: <96tn5s02d5q@drn.newsguy.com>

In article <lrsk6.1262$_Q.4408490_at_nnrp3.proxad.net>, "Douglas says...
>
>Hello,
>
>I have an error in my JSP pages and don't know how to fixe it. Tih is my
>error :
>
>javax.servlet.ServletException: Exception thrown on line '197' from page
>'D:\\web\\Medicale\\Web\\index.jsp'.
> java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY
> at
>sun.jdbc.odbc.JdbcOdbcResultSet.isBeforeFirst(JdbcOdbcResultSet.java:1925)
> at jrun__index2ejspa._jspService(jrun__index2ejspa.java:90)
> at allaire.jrun.jsp.HttpJSPServlet.service(HttpJSPServlet.java:40)
>
>and this is my code :
>
> <%myConnect.connect();
>
> String sqlActu = "";
>
> sqlActu = "SELECT Titre FROM Actualite ";
> sqlActu = sqlActu + "WHERE Status='V' ";
> sqlActu = sqlActu + "AND DateDebutAffichage <= " +
>myUtil.DateRequest(Calendar.getInstance()) + " ";
> sqlActu = sqlActu + "AND DateFinAffichage >= " +
>myUtil.DateRequest(Calendar.getInstance()) + " ";
> //out.println(sqlActu);
> ResultSet rsActualite = myConnect.execSQL(sqlActu);
> if (rsActualite.isBeforeFirst()){ // this is the 197 line
> rsActualite.last();
> int MaxActualite = rsActualite.getRow();
> rsActualite.beforeFirst();
> //out.println(MaxActualite + "<br>");
>
>Does anyone have an idea ?
>
>thanks,
>
>Douglas.
>
>

I know almost zilch about JSP, but this looks quite obvious. In Oracle resultsets you can only move forward. When opening the resultset the resultset is at the first record. Your call tries to move backward before the first row. As Oracle resultsets are forward only, this is not going to work Word of advice: one of the most frequent issues I am having with jsp developers they always build sql like above example, and they *never* use parameters. I know you can do that in jdbc, and you should do that wherever you can, because using hardcoded literals instead of parameters is one of the most safe performance killers: you will force Oracle to perform an hard parse.

Hth,

Sybrand Bakker, Oracle DBA Received on Tue Feb 20 2001 - 06:15:56 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US