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


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3855367#3855367

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3855367


-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to