2 Replies Latest reply on Sep 28, 2002 10:24 AM by max goff

    Access DataSource from MBean

    max goff Newbie

      How do I access a datasource from an mbean ? I have successfully deployed a datasource that points to an Oracle database in deploy/Oracle-service.xml. This datasource is accessible from other deployed session beans.
      I have shown a code snippet from my mbean that throws a NameNotFoundException:
      try {
      javax.naming.InitialContext context = new javax.naming.InitialContext();
      javax.sql.DataSource objDataSource = (javax.sql.DataSource) context.lookup("OracleDS"); Connection objConn = objDataSource.getConnection();
      } catch(javax.naming.NamingException exNaming) {
      exNaming.printStackTrace();
      } catch(java.sql.SQLException sqlEx){
      sqlEx.printStackTrace();
      }

      I can see the datasource deployed in the JMX HTML view under jboss.jca :-
      service=CachedConnectionManager
      service=LocalTxCM,name=OracleDS
      service=LocalTxDS,name=OracleDS
      service=LocalTxPool,name=OracleDS
      service=RARDeployer
      service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper
      service=RARDeployment,name=JMS Adapter
      service=RARDeployment,name=Minerva JDBC XATransaction ResourceAdapter
      service=XaTxCM,name=jmsra
      service=XaTxDS,name=jmsra
      service=XaTxPool,name=jmsra