1 Reply Latest reply on Nov 8, 2004 11:55 AM by a d

    Accessing Datasource error

    a d Newbie

      Hello,

      I have got some problem in trying to access my mySQL DB from my ear.
      I use Jboss4.0 with MySQL and I have got the following error in Jboss console:


      14:40:05,625 INFO [STDOUT] javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: jdbc_AdminDB not bound]
      14:40:05,625 INFO [STDOUT] at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:971)
      14:40:05,625 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:614)
      14:40:05,625 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:643)
      14:40:05,625 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:508)
      14:40:05,625 INFO [STDOUT] at javax.naming.InitialContext.lookup(InitialContext.java:347)
      14:40:05,625 INFO [STDOUT] at com.iratensolutions.applications.ejb.admin.tools.AdminTools.getConnection(AdminTools.java:36)


      But when I look in the begining of the Jboss console I can see that jdbc_AdminDB is known :

      14:39:23,406 INFO [WrapperDataSourceService] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:name=jdbc_AdminDB,service=DataSourceBinding to JNDI name 'java:jdbc_AdminDB'


      Here is a part of my jboss.xml File:
       <session>
       <ejb-name>ConfigModuleDBTasksBean</ejb-name>
       <local-jndi-name>ConfigModuleDBTasksLocalHome</local-jndi-name>
       <resource-ref>
       <res-ref-name>jdbc/AdminDB</res-ref-name>
       <jndi-name>jdbc_AdminDB</jndi-name>
       </resource-ref>
       </session>
      


      Here is the way I call my DB from my code

       static public Connection getConnection(InitialContext jndiContext) {
       Connection connection = null;
       try {
       DataSource ds = (DataSource) jndiContext.lookup("java:comp/env/jdbc/AdminDB");
       connection = ds.getConnection();
       } catch (NamingException ne) {
       AdminAgentLogger.logException(ne);
       } catch (SQLException sqle) {
       String message = "Error when connecting to the Administration database. Maybe you don't have access rights.";
       AdminAgentLogger.logException(message, sqle);
       }
       return connection;
       }
      


      And finally my Admin-ds.xml file
      <?xml version="1.0" encoding="UTF-8"?>
      
      <!-- $Id: mysql-ds.xml,v 1.2 2003/12/12 19:22:31 starksm Exp $ -->
      <!-- Datasource config for MySQL using 3.0.9 available from:
      http://www.mysql.com/downloads/api-jdbc-stable.html
      -->
      
      <datasources>
       <local-tx-datasource>
       <jndi-name>jdbc_AdminDB</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/admin13b</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>root</user-name>
       <password>tenari</password>
       </local-tx-datasource>
      
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
      </datasources>
      


      Where am I doing wrong ? I think its a problem of configuration
      please help
      Thanks in advance