[jboss-user] [JCA/JBoss] - Re: How can I test if a Datasource is correctly installed

weston.price@jboss.com do-not-reply at jboss.com
Sat Oct 13 13:32:16 EDT 2007


Such as? 

Psuedo code in Servlet or EJB

  | 
  |    InitialContext ctx =  null;
  |    DataSource ds = null;
  |    Connection c = null;
  | 
  |    try
  |    {
  |      ctx = new InitialContext();
  |      ds = ctx.lookup("JNDINAME OF DATASOURCE HERE");
  |      c = ds.getConnection();
  |      
  |    }catch(SQLException e)
  |    { 
  |        System.out.println(e.getMessage());
  | 
  |    }
  |   finally
  |   {
  |      if(c != null)
  |        c.close();
  |          
  |      if(ctx != null)
  |        ctx.close();
  |   }
  | 
  | 


There are plenty of other examples out there as well. I recommend the J2EE tutorial as a place to start if the above concepts are not familiar to you.




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

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



More information about the jboss-user mailing list