DataSource lookup in Client Code in JBOSS 2.2.4


EJB programming & troubleshooting: DataSource lookup in Client Code in JBOSS 2.2.4

  1. DataSource lookup in Client Code in JBOSS 2.2.4 (3 messages)

    i am using the JBOss 2.2.4 integrated with catalina server.
    I have set the datasource in the jboss_home\conf\catalina\jboss.jcml file as given below.

      <mbean code="org.jboss.jdbc.JdbcProvider" name="DefaultDomain:service=JdbcProvider">
         <attribute name="Drivers">oracle.jdbc.driver.OracleDriver</attribute>

       <mbean code="org.jboss.jdbc.XADataSourceLoader" name="DefaultDomain:service=XADataSource,name=OracleDBPool">
        <attribute name="PoolName">OracleDBPool</attribute>
        <attribute name="DataSourceClass">org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl</attribute>
        <attribute name="Properties"></attribute>
        <attribute name="URL">jdbc:oracle:thin:@oraserver:1521:coutts</attribute>
        <attribute name="GCMinIdleTime">1200000</attribute>
        <attribute name="JDBCUser">eplus</attribute>
        <attribute name="MaxSize">10</attribute>
        <attribute name="Password">eplus</attribute>
        <attribute name="GCEnabled">false</attribute>
        <attribute name="InvalidateOnError">false</attribute>
        <attribute name="TimestampUsed">false</attribute>
        <attribute name="Blocking">true</attribute>
        <attribute name="GCInterval">120000</attribute>
        <attribute name="IdleTimeout">1800000</attribute>
        <attribute name="IdleTimeoutEnabled">false</attribute>
        <attribute name="LoggingEnabled">false</attribute>
        <attribute name="MaxIdleTimeoutPercent">1.0</attribute>
        <attribute name="MinSize">0</attribute>

    I want to lookup the above datasource in my java client code
    as given below:

    public static void main(String[] args)

    //Sybase jconnect driver
    Properties env=new Properties();


    InitialContext namingContext = new InitialContext(env);

    Object obj=namingContext.lookup("java:/OracleDS");
    // DataSource ds = (DataSource)obj;
              System.out.println("--Driver load driver--"+obj);
    }catch(Exception e){
    System.out.println("No DataSource to look up-->"+e.getMessage());
    }//end of catch
    System.out.println("---Hello World!---");

    }//end of main

    But it gives me name not bound and unable to lookup.

    Can anybody help me on this problem.

    Thanks in advance,

    Jignesh Shah
  2. Hi,
       I dont think that is possible. The (DB)connections can be used only by the beans, but not by the clients. This is as per my knowledge. If it is possible in any server pl. le t me know.
  3. actually, I did it once with tomcat32x and jboss using minerva. So I know that it's possible, but for the life of me I can't find the code I wrote.

    Sorry that's not more helpful.
  4. The main problem about applied code for accessing JNDI tree from client code i that client what to access to java:/ subtree which in my opinion can only be accessed from some JVM machine e.g. client code and jboss must be at the same jvm