5 Replies Latest reply on Nov 10, 2002 5:24 PM by Ian McDermid

    Pooled Data Source

    Ian McDermid Newbie

      I am having great trouble getting a pooled data source to work.

      when Jboss starts up, i see the following message on the screen:

      [INFO,myOracleDS] Starting
      [INFO,myOracleDS] XA Connection pool myOracleDS bound to java:/myOracleDS
      [INFO,myOracleDS] Started

      I have setup an mbean in jboss.jcml


      myOracleDS
      org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl

      jdbc:oracle:oci8:@oralin
      beg
      10
      java
      false
      false
      false
      true
      120000
      1800000
      false
      false
      1.0
      0


      When I run the code I get the following error:

      Something Failed: myOracleDS not bound
      javax.naming.NameNotFoundException: myOracleDS not bound
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:333)
      at javax.naming.InitialContext.lookup(InitialContext.java:350)
      at DSConnect.main(DSConnect.java:26)

      the source code is:

      import java.sql.*;
      import javax.sql.*;
      import javax.naming.*;
      import java.util.*;

      public class DSConnect {

      public static void main(String[] args) throws Exception {

      try {

      //setup initial context

      Properties env = new Properties();

      env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      env.setProperty("java.naming.provider.url", "localhost:1099");
      env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");

      //get Initial context

      InitialContext ic = new InitialContext(env);

      //lookup Datasource

      ConnectionPoolDataSource ds = (ConnectionPoolDataSource)ic.lookup("java:/myOracleDS");

      //Get Connection

      PooledConnection pc = ds.getPooledConnection();

      Connection conn = pc.getConnection();

      conn.close();

      }
      catch(Exception e) {
      System.out.println("Something Failed: " + e.getMessage());
      e.printStackTrace();
      }
      }
      }



      Can anyone please tell me what is wrong

      Tks

        • 1. Re: Pooled Data Source
          Ian McDermid Newbie

          > I am having great trouble getting a pooled data
          > source to work.
          >
          > when Jboss starts up, i see the following message on
          > the screen:
          >
          > [INFO,myOracleDS] Starting
          > [INFO,myOracleDS] XA Connection pool myOracleDS bound
          > to java:/myOracleDS
          > [INFO,myOracleDS] Started
          >
          > I have setup an mbean in jboss.jcml
          >
          > "
          > name="DefaultDomain:service=XADataSource,name=myOracle
          > S">
          > myOracleDS
          > e
          > name="DataSourceClass">org.jboss.pool.jdbc.xa.wrapper.
          > ADataSourceImpl
          >
          > e name="URL">jdbc:oracle:oci8:@oralin
          > beg
          > 10
          > java
          > false
          > e name="InvalidateOnError">false
          > false
          > true
          > 120000
          > 1800000
          > e name="IdleTimeoutEnabled">false
          > false
          > e name="MaxIdleTimeoutPercent">1.0
          > 0
          >
          >
          > When I run the code I get the following error:
          >
          > Something Failed: myOracleDS not bound
          > javax.naming.NameNotFoundException: myOracleDS not
          > bound
          > at
          > sun.rmi.transport.StreamRemoteCall.exceptionReceivedF
          > omServer(StreamRemoteCall.java:245)
          > at
          > sun.rmi.transport.StreamRemoteCall.executeCall(Stream
          > emoteCall.java:220)
          > at
          > sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
          >
          > at org.jnp.server.NamingServer_Stub.lookup(Unknown
          > Source)
          > at
          > org.jnp.interfaces.NamingContext.lookup(NamingContext
          > java:349)
          > at
          > org.jnp.interfaces.NamingContext.lookup(NamingContext
          > java:333)
          > at
          > javax.naming.InitialContext.lookup(InitialContext.jav
          > :350)
          > at DSConnect.main(DSConnect.java:26)
          >
          > the source code is:
          >
          > import java.sql.*;
          > import javax.sql.*;
          > import javax.naming.*;
          > import java.util.*;
          >
          > public class DSConnect {
          >
          > public static void main(String[] args) throws
          > Exception {
          >
          > try {
          >
          > //setup initial context
          >
          > Properties env = new Properties();
          >
          > env.setProperty("java.naming.factory.initial",
          > ", "org.jnp.interfaces.NamingContextFactory");
          > env.setProperty("java.naming.provider.url",
          > ", "localhost:1099");
          > env.setProperty("java.naming.factory.url.pkgs",
          > ", "org.jboss.naming");
          >
          > //get Initial context
          >
          > InitialContext ic = new InitialContext(env);
          >
          > //lookup Datasource
          >
          > ConnectionPoolDataSource ds =
          > =
          > (ConnectionPoolDataSource)ic.lookup("java:/myOracleDS
          > );
          >
          > //Get Connection
          >
          > PooledConnection pc = ds.getPooledConnection();
          >
          > Connection conn = pc.getConnection();
          >
          > conn.close();
          >
          > }
          > catch(Exception e) {
          > System.out.println("Something Failed: " +
          > + e.getMessage());
          > e.printStackTrace();
          > }
          > }
          > }
          >
          >
          >
          > Can anyone please tell me what is wrong
          >
          > Tks

          Iam running 2.4.4 with tomcat

          • 2. Re: Pooled Data Source
            Ian McDermid Newbie

            > I am having great trouble getting a pooled data
            > source to work.
            >
            > when Jboss starts up, i see the following message on
            > the screen:
            >
            > [INFO,myOracleDS] Starting
            > [INFO,myOracleDS] XA Connection pool myOracleDS bound
            > to java:/myOracleDS
            > [INFO,myOracleDS] Started
            >
            > I have setup an mbean in jboss.jcml
            >
            > "
            > name="DefaultDomain:service=XADataSource,name=myOracle
            > S">
            > myOracleDS
            > e
            > name="DataSourceClass">org.jboss.pool.jdbc.xa.wrapper.
            > ADataSourceImpl
            >
            > e name="URL">jdbc:oracle:oci8:@oralin
            > beg
            > 10
            > java
            > false
            > e name="InvalidateOnError">false
            > false
            > true
            > 120000
            > 1800000
            > e name="IdleTimeoutEnabled">false
            > false
            > e name="MaxIdleTimeoutPercent">1.0
            > 0
            >
            >
            > When I run the code I get the following error:
            >
            > Something Failed: myOracleDS not bound
            > javax.naming.NameNotFoundException: myOracleDS not
            > bound
            > at
            > sun.rmi.transport.StreamRemoteCall.exceptionReceivedF
            > omServer(StreamRemoteCall.java:245)
            > at
            > sun.rmi.transport.StreamRemoteCall.executeCall(Stream
            > emoteCall.java:220)
            > at
            > sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
            >
            > at org.jnp.server.NamingServer_Stub.lookup(Unknown
            > Source)
            > at
            > org.jnp.interfaces.NamingContext.lookup(NamingContext
            > java:349)
            > at
            > org.jnp.interfaces.NamingContext.lookup(NamingContext
            > java:333)
            > at
            > javax.naming.InitialContext.lookup(InitialContext.jav
            > :350)
            > at DSConnect.main(DSConnect.java:26)
            >
            > the source code is:
            >
            > import java.sql.*;
            > import javax.sql.*;
            > import javax.naming.*;
            > import java.util.*;
            >
            > public class DSConnect {
            >
            > public static void main(String[] args) throws
            > Exception {
            >
            > try {
            >
            > //setup initial context
            >
            > Properties env = new Properties();
            >
            > env.setProperty("java.naming.factory.initial",
            > ", "org.jnp.interfaces.NamingContextFactory");
            > env.setProperty("java.naming.provider.url",
            > ", "localhost:1099");
            > env.setProperty("java.naming.factory.url.pkgs",
            > ", "org.jboss.naming");
            >
            > //get Initial context
            >
            > InitialContext ic = new InitialContext(env);
            >
            > //lookup Datasource
            >
            > ConnectionPoolDataSource ds =
            > =
            > (ConnectionPoolDataSource)ic.lookup("java:/myOracleDS
            > );
            >
            > //Get Connection
            >
            > PooledConnection pc = ds.getPooledConnection();
            >
            > Connection conn = pc.getConnection();
            >
            > conn.close();
            >
            > }
            > catch(Exception e) {
            > System.out.println("Something Failed: " +
            > + e.getMessage());
            > e.printStackTrace();
            > }
            > }
            > }
            >
            >
            >
            > Can anyone please tell me what is wrong
            >
            > Tks

            Iam running 2.4.4 with tomcat

            • 3. Re: Pooled Data Source
              Ian McDermid Newbie

              I am using 2.4.4

              • 4. Re: Pooled Data Source
                Johann Schipfer Newbie

                The datasource is bound under the java: namespace, which means, it is only visible inside the application server, therefore the JNDI lookup from a standalone client fails.

                • 5. Re: Pooled Data Source
                  Ian McDermid Newbie

                  Thanks for your reply. I have managed to get it to work within an EJB. Does anyone know any way a Datasource can be used form a standalone client ??