Please, could somebody tell me how to use a DB connection pool from a web 
application inside JBoss.

I've tried everything including reinstalling and configuring JBoss step by step.

I've deleted all other applications and configured a little one that makes:


  | 
  | public class MyTest extends HttpServlet {
  | 
  |     public void doGet(HttpServletRequest request, HttpServletResponse 
response)
  |             throws ServletException {
  |         doPost(request, response);
  |     }
  | 
  |     public void doPost(HttpServletRequest request, HttpServletResponse 
response)
  |             throws ServletException {
  |         try {
  |             InitialContext ctx = new InitialContext();
  | 
  |             /*
  |             * Lookup the DataSource, which will be backed by a pool
  |             * that the application server provides. DataSource instances
  |             * are also a good candidate for caching as an instance
  |             * variable, as JNDI lookups can be expensive as well.
  |             */
  | 
  |             DataSource ds = (DataSource) 
ctx.lookup("java:comp/env/jdbc/MySQLDB");
  | 
  |             /*
  |             * The following code is what would actually be in your
  |             * Servlet, JSP or EJB 'service' method...where you need
  |             * to work with a JDBC connection.
  |             */
  | 
  |             Connection conn = null;
  |             Statement stmt = null;
  | 
  | 
  |             conn = ds.getConnection();
  | 
  |             if (conn != null)
  |                 System.out.println("It's OK");
  |             else
  |                 System.out.println("Tooo bad !");
  | 
  |         } catch (Exception e) {
  |             throw new ServletException(e.getMessage());
  |         }
  |     }
  | 
  | 


I'm receiving the same error.

I wonder which is the right way to use a DS from a servlet...


Thanks in advance.

J



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

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


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to