2 Replies Latest reply on Oct 3, 2002 3:03 PM by Markus

    Hypersonic count() failure throwing ServletException

    Markus Newbie

      Hi,

      I'm trying to get the row count of a table. I've used the following code:

      Context lContext = new InitialContext();
      DataSource aSource = (DataSource) lContext.lookup( "java:/DefaultDS" );
      Connection aConnection = aSource.getConnection();
      Statement aStatement = aConnection.createStatement();
      String aSql = "SELECT COUNT(I_ID) AS C FROM ITEM";
      ResultSet aResult = aStatement.executeQuery( aSql );
      int maxItems = aResult.getInt(1);


      But I always get the following exception (another get-type doesn't help):

      javax.servlet.ServletException:
      at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:463)
      at org.apache.jsp.index$jsp._jspService(index$jsp.java:103)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      [...]


      I've used the HSQL Database Manager to check out if the SQL statement works, and it does. If I use something like "SELECT * FROM ITEM" it works. Can anybody help me?

      Thanks,
      Markus