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>
<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>
... 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()); } ...