Hi

I've a simple web application in JBoss AS that will need to connect to a MySQL 
DB then I did in WEB-INF of deployed:

jboss-web.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | <jboss-web>
  |     <resource-ref>
  |         <res-ref-name>jdbc/MySQLDB</res-ref-name>
  |         <res-type>javax.sql.DataSource</res-type>
  |         <jndi-name>java:MySQLDB</jndi-name>
  |     </resource-ref>
  | </jboss-web>
  | 


web.xml

  | <resource-ref>
  |         <description>The default MySQL DS</description>
  |         <res-ref-name>jdbc/MySQLDB</res-ref-name>
  |         <res-type>javax.sql.DataSource</res-type>
  |         <res-auth>Container</res-auth>
  |     </resource-ref>
  | 



Adn in my code I did:


  | public static Connection getConnection() throws Exception {
  |         Connection conn = null;
  |         Context envContext = null;
  | 
  |         logger.info( "NOTIFICATIONS: Trying to access to Connection");
  | 
  |         try {
  |             Context initContext = new InitialContext();
  |             envContext = (Context) 
initContext.lookup(DBConnection.LOOKUP_LABEL);
  |         } catch (NamingException ne) {
  |             logger.error( "NOTIFICATIONS: Error ne en LOOKUP al intentar 
conseguir conectar al DB pool: " + ne.getMessage());
  |         } catch (Exception e) {
  |             logger.error( "NOTIFICATIONS: Error e en LOOKUP al intentar 
conseguir conectar al DB pool: " + e.getMessage());
  |         }
  | 
  |         try {
  |             DataSource ds = (DataSource) 
envContext.lookup(DBConnection.DATASOURCE_LABEL);
  |             conn = ds.getConnection();
  |         } catch (NamingException ne) {
  |             logger.error( "NOTIFICATIONS: Error ne en DATASOURCE al 
intentar conseguir conectar al DB pool: " + ne.getMessage());
  |         } catch (NullPointerException npe) {
  |             logger.error( "NOTIFICATIONS: Error npe en DATASOURCE al 
intentar conseguir conectar al DB pool: " + npe.getMessage());
  |         } catch (SQLException sqle) {
  |             logger.error( "NOTIFICATIONS: Error sqle en DATASOURCE al 
intentar conseguir conectar al DB pool: " + sqle.getMessage());
  |         } catch (Exception e) {
  |             logger.error( "NOTIFICATIONS: Error en DATASOURCE al intentar 
conseguir conectar al DB pool: " + e.getMessage());
  |         }
  | 



But when my app try to connect I got the message:


  | 12:35:06,950 INFO  [DBConnection] NOTIFICATIONS: Trying to access to 
Connection
  | 12:35:06,955 ERROR [DBConnection] NOTIFICATIONS: Error ne en DATASOURCE al 
intentar conseguir conectar al DB pool: Could not dereference object
  | 


Could somebody tell me what am I doing wrong ?


Thanks in advance

J



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

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


-------------------------------------------------------
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