0 Replies Latest reply on Nov 16, 2004 10:10 AM by Uno Engborg

    Empty Resultset from Firebird in Tomcat Servlet

    Uno Engborg Newbie

      I try to set up a servlet to connect to a firebird database. It seams that I can lookup the Datasource and get a Connection. I then create a Statement and do executeQuery. I get back a ResulSset. The problem is that the ResultSet is empty. Even though it shouldn't be.

      I use the Firebird-ds.xml file from the example directory and have only altered the database location, and sysdba password to fit my Firebird setup.
      The firebirdsql.rar seams to be deployed OK.

      The datasource shows in the jmx-web console JNDI view as java:FirbirdDS

      My web.xml :

      <web-app >
       <distributable/>
      
       <servlet>
       <servlet-name>Test</servlet-name>
       <display-name>Name for Test</display-name>
       <description><![CDATA[Description for Test]]></description>
       <servlet-class>MyTestServlet</servlet-class>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>Test</servlet-name>
       <url-pattern>/A</url-pattern>
       </servlet-mapping>
      
       <resource-ref >
       <res-ref-name>/jdbc/FirebirdDS</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
      
      </web-app>
      
      

      My jboss-web.xml:

      <jboss-web>
      
       <context-root>/</context-root>
      
       <resource-ref>
       <jndi-name>java:FirebirdDS</jndi-name>
       <res-ref-name>/jdbc/FirebirdDS</res-ref-name>
       </resource-ref>
      
      </jboss-web>
      

      The calling code in the servlet looks like this

      ...
      ServletContext cont=config.getServletContext();
      try {
       InitialContext context=new InitialContext();
       ds=(DataSource)context.lookup("java:/comp/env/jdbc/FirebirdDS");
      } catch (NamingException e) {
       e.printStackTrace();
      }
      ...
      try{
       Connection con=ds.getConnection("sysdba","masterkey");
       Statement stmt=con.createStatement();
       ResultSet res=stmt.executeQuery("select * from test");
       p.println("<table>");
       while(res.next()){
       String s=res.getString("FNAME");
       p.println("<tr><td>"+s+"</td></tr>");
       }
       p.println("</table>");
      
      }catch(java.sql.SQLException e){
       p.println("Frågan misslyckades"+e.getMessage());
      }
      ...
      


      I use JBoss 4.00 with Tomcat servlet container. Sun Jdk1.5.0, Win2k
      Firebird 1.51, JayBird 1.54