4 Replies Latest reply on Oct 25, 2002 2:28 PM by Diogo Catossi

    How To get the Context for DataSource ?

    Praveen Newbie

      Hey Guys

      Can you please tell me how to get the context for datasource.

      I am using following look-up , but it is giving error.

      InitialContext ic = new InitialContext();
      DataSource ds = (DataSource) ic.lookup("jdbc/MYDB");

      Error: jdbc not found.

      can you help me ?


        • 1. Re: How To get the Context for DataSource ?
          James Moring Newbie

          Assuming you have setup the datasource source correctly, the following should work:

          InitialContext ic = new InitialContext();
          DataSource ds = (DataSource) ic.lookup("java:/MYDB");


          • 2. Re: How To get the Context for DataSource ?
            Praveen Newbie

            Thanks for your response.

            Now it is giving different error. it is saying not able to find my Datasource. I pasted my oracle-service.xml which is in /default/deploy dir of Jboss

            **************** oracle-service.xml ****************

            <!-- ==================================================================== -->
            <!-- New ConnectionManager setup for default hsql dbs -->
            <!-- Build jmx-api (build/build.sh all) and view for config documentation -->
            <!-- ==================================================================== -->

            <depends optional-attribute-name="ManagedConnectionFactoryName">
            <!--embedded mbean-->


            <config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:thin:@cmisdb.cmisdev.org:1521:DEVORA1</config-property>
            <config-property name="DriverClass" type="java.lang.String">oracle.jdbc.driver.OracleDriver</config-property>
            <config-property name="UserName" type="java.lang.String">cmis</config-property>
            <config-property name="Password" type="java.lang.String">cmis001</config-property>

            <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper

            <depends optional-attribute-name="ManagedConnectionPool">
            <!--embedded mbean-->


            <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager
            <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager
            <!--make the rar deploy! hack till better deployment-->

            ********************** end of oracle-service.xml **********
            PS: I have classes12.jar under lib dir, which is in path

            can please tell what could be the problem


            • 3. Re: How To get the Context for DataSource ?
              Tung Dang Novice

              You can look up the correct name of your datasource under service=JNDIView from http://localhost:8082 (JBoss 3.0) or for Jboss3.0.1 http://localhost:8080/jmx-console.

              Hope it helps.

              • 4. Re: How To get the Context for DataSource ?
                Diogo Catossi Newbie

                try putting the JNDIName in your connection like this:

                DataSource ds = (DataSource) ic.lookup("java:/CMISDS");