4 Replies Latest reply on Dec 16, 2001 9:14 PM by IPOz

    about SQL SERVER JNDI name

    IPOz Newbie

      Hi,friends
      By visiting 8082 port i am sure the M$ SQL Server pool has been created successfully.Its name is SQLServerPool.The following is the code snipper used to test this pool:
      ...
      private static DataSource getDataSource()
      throws NamingException
      {
      try {
      InputStream stream = TestServer.class.getClassLoader().getResourceAsStream("jndi.properties");
      if (stream != null) {
      System.getProperties().load(stream);
      System.out.println("initial = "+System.getProperty("java.naming.factory.initial"));
      System.out.println("provider = "+System.getProperty("java.naming.provider.url"));
      }
      }
      catch (Exception exception) {}


      try {
      InitialContext ic = new InitialContext();
      return (DataSource) ic.lookup("java:/SQLServerPool");
      }
      catch (NamingException e) {
      System.out.println(e.getMessage());
      return null;
      }
      }
      ....
      The jndi.properties's content is:
      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=localhost:1099
      java.naming.factory.url.pkgs=org.jboss.naming

      When i run it it reports "SQLServerPool not bound"

      How can i resolve it?

      Any suggestions are appreciated!

        • 1. Re: about SQL SERVER JNDI name
          IPOz Newbie

          It is similar using java:comp/env/jdbc/SQLServerPool instead of java:SQLServerPool.
          ...
          comp not bound
          javax.naming.NameNotFoundException: comp not bound
          at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
          RemoteCall.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 TestServer.getDataSource(TestServer.java:59)
          at TestServer.main(TestServer.java:26)

          Any suggestion?

          • 2. Re: about SQL SERVER JNDI name
            IPOz Newbie

            It seems that the SQL pool can only be looked up in the JBoss environment.So i use the following session bean to test it.
            import javax.ejb.*;
            import javax.transaction.*;
            import java.sql.*;
            import javax.sql.*;
            import javax.naming.*;

            public class BMTTestBean implements SessionBean
            {
            private SessionContext sessionContext;
            private UserTransaction ut;
            private DataSource ds;

            public void ejbCreate() throws CreateException
            {
            }

            public void ejbRemove()
            {
            }

            public void ejbActivate()
            {
            }

            public void ejbPassivate()
            {
            }

            public void setSessionContext(SessionContext context)
            {
            sessionContext = context;
            }

            public void testOne()
            {
            Connection con = null;
            PreparedStatement stmt = null;

            StringBuffer sbf1 = new StringBuffer("Insert into xz_doc_type(doc_type_id, doc_type_name) values (1,'Robin Paul')");
            try {
            con = getConnection();
            if(con != null)
            System.out.println("row size=" + con.getMetaData().getMaxRowSize());
            else
            System.out.println("no connection");
            stmt = con.prepareStatement(sbf1.toString());
            sbf1 = null;
            stmt.executeUpdate();
            stmt.close();
            }
            catch( Exception se ) {
            System.out.println(se.getMessage());
            // se.printStackTrace();
            }
            }

            private Connection getConnection() throws Exception
            {
            InitialContext initCtx = null;
            initCtx = new InitialContext();
            ds = (javax.sql.DataSource) initCtx.lookup("java:comp/env/jdbc/SQLServerPool");
            initCtx.close();
            return ds.getConnection();
            }
            }
            The connection was created successfully however it reported that xz_doc_type didnot exist.And System.out.println("row size=" + con.getMetaData().getMaxRowSize()) returned 0.

            What's wrong with the SQLServerPool?

            Best Regards!

            • 3. Re: about SQL SERVER JNDI name
              alex.lee Newbie

              Hi zeng,
              Pls post the JDBC's configuration of the jboss.jcml;

              • 4. my jboss.jcml
                IPOz Newbie

                <?xml version="1.0" encoding="UTF-8"?>
                <!-- This is where you can add and configure your MBeans
                ATTENTION: The order of the listing here is the same order as
                the MBeans are loaded. Therefore if a MBean depends on another
                MBean to be loaded and started it has to be listed after all
                the MBeans it depends on.
                -->


                <!-- ==================================================================== -->
                <!-- Classloading -->
                <!-- ==================================================================== -->

                8083
                <!-- Should resources and non-EJB classes be downloadable -->
                true


                <!-- ==================================================================== -->
                <!-- JNDI -->
                <!-- ==================================================================== -->

                1099




                <!-- ==================================================================== -->
                <!-- Transactions -->
                <!-- ==================================================================== -->

                300

                <!-- Use this attribute if you need to use a specific Xid
                implementation
                oracle.jdbc.xa.OracleXid
                -->


                <!-- Uncomment to use Tyrex (tyrex.exolab.org) transaction manager plugin
                instead of the org.jboss.tm.TransactionManagerService and comment out
                the TransactionManagerService above

                ../conf/default/domain.xml

                -->





                <!-- ==================================================================== -->
                <!-- Security -->
                <!-- ==================================================================== -->

                <!-- JAAS security manager and realm mapping -->

                org.jboss.security.plugins.JaasSecurityManager



                <!-- ==================================================================== -->
                <!-- JDBC -->
                <!-- ==================================================================== -->



                org.hsqldb.jdbcDriver,com.microsoft.jdbc.sqlserver.SQLServerDriver




                1476
                true
                default
                false



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

                jdbc:hsqldb:hsql://localhost:1476
                1200000
                sa
                10

                false
                false
                false
                true
                120000
                1800000
                false
                false
                1.0
                0



                SQLServerPool
                org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
                jdbc:microsoft:sqlserver://192.168.1.129:1433
                ihpms
                ihpms


                <!-- ==================================================================== -->
                <!-- JBoss Server Management -->
                <!-- ==================================================================== -->

                5000


                <!-- ==================================================================== -->
                <!-- J2EE deployment -->
                <!-- ==================================================================== -->


                true
                false
                false
                true
                false


                <!-- Uncomment to add embedded tomcat service -->


                <!-- Uncomment and set file URL to add Jetty service (you can set config more than once)

                file URL to jetty.xml e.g. file:/usr/local/jboss/dist/conf/default/jetty.xml

                -->


                <!-- ==================================================================== -->
                <!-- JBossMQ -->
                <!-- ==================================================================== -->


                <!-- The StateManager is used to keep JMS perisitent state data. -->
                <!-- For example: what durable subscriptions are active. -->

                jbossmq-state.xml


                <!-- The PersistenceManager is used to store messages to disk. -->

                ../../db/jbossmq/


                <!-- InvocationLayers are the different transport methods that can be used to access the server -->

                java:/ConnectionFactory
                java:/XAConnectionFactory



                RMIConnectionFactory
                RMIXAConnectionFactory



                ConnectionFactory
                XAConnectionFactory



                UILConnectionFactory
                UILXAConnectionFactory


                <!-- The following three line create 3 topics named: testTopic, example, and bob -->




                <!-- The following 9 line create 9 topics named: testQueue, controlQueue, A, B, -->
                <!-- C, D, E, F, and ex -->










                <!-- Used for backwards compatability with JBossMQ versions before 1.0.0 -->

                ConnectionFactory
                QueueConnectionFactory


                ConnectionFactory
                TopicConnectionFactory


                <!-- For Message Driven Beans -->

                DefaultJMSProvider
                org.jboss.jms.jndi.JBossMQProvider
                java:/XAConnectionFactory
                java:/XAConnectionFactory


                StdJMSPool
                org.jboss.jms.asf.StdServerSessionPoolFactory



                <!-- Make sure you change EmbeddedTomcat to Jetty if you are using Jetty -->

                Default
                :service=ContainerFactory
                :service=EmbeddedTomcat


                <!-- Uncomment this and disable previous J2eeDeployer entry to enable an alternative "scoped" deployment

                Default
                :service=ContainerFactory
                :service=EmbeddedTomcat

                -->

                <!-- ==================================================================== -->
                <!-- JBossCX setup, for J2EE connector architecture support -->
                <!-- ==================================================================== -->




                <!-- Minerva no transaction connection manager factory.

                Use this for resource adapters that don't support
                transactions. -->

                MinervaNoTransCMFactory

                org.jboss.pool.connector.jboss.MinervaNoTransCMFactory




                <!-- Minerva local transaction connection manager factory.

                Use this for resource adapters that support "local"
                transactions. -->

                MinervaSharedLocalCMFactory

                org.jboss.pool.connector.jboss.MinervaSharedLocalCMFactory




                <!-- Minerva XA transaction connection manager factory

                Use this for resource adapters that support "xa"
                transactions. -->

                MinervaXACMFactory

                org.jboss.pool.connector.jboss.MinervaXACMFactory




                <!-- Connection factory for the Minerva JDBC resource adapter. This
                points at the same database as DefaultDS. -->

                MinervaDS
                JCA:service=RARDeployer

                Minerva JDBC LocalTransaction ResourceAdapter


                ConnectionURL=jdbc:HypersonicSQL:hsql://localhost:1476



                MinervaSharedLocalCMFactory

                <!-- See the documentation for the specific connection manager
                implementation you are using for the properties you can set -->

                # Pool type - uncomment to force, otherwise it is the default
                #PoolConfiguration=per-factory

                # Connection pooling properties - see
                # org.jboss.pool.PoolParameters
                MinSize=0
                MaxSize=10
                Blocking=true
                GCEnabled=false
                IdleTimeoutEnabled=false
                InvalidateOnError=false
                TrackLastUsed=false
                GCIntervalMillis=120000
                GCMinIdleMillis=1200000
                IdleTimeoutMillis=1800000
                MaxIdleTimeoutPercent=1.0


                <!-- Principal mapping configuration -->

                org.jboss.resource.security.ManyToOnePrincipalMapping


                userName=sa
                password=



                <!-- This is an example of using a resource adapter that supports XA
                transactions. The Minerva XA resource adapter requires an
                XADataSource to be in JNDI somewhere. JBoss doesn't include a
                database with an XA-compliant JDBC driver, so this will need to
                be configured to use whatever XADataSource implementation you
                have.


                MinervaXADS

                Put your XADataSource implementation class here





                XAMinervaDS
                JCA:service=RARDeployer

                Minerva JDBA XA Resource Adapter


                XADataSourceName=java:/MinervaXADS



                MinervaXACMFactory


                # Pool type - uncomment to force, otherwise it is the default
                #PoolConfiguration=per-factory

                # Connection pooling properties - see
                # org.jboss.pool.PoolParameters
                MinSize=0
                MaxSize=10
                Blocking=true
                GCEnabled=false
                IdleTimeoutEnabled=false
                InvalidateOnError=false
                TrackLastUsed=false
                GCIntervalMillis=120000
                GCMinIdleMillis=1200000
                IdleTimeoutMillis=1800000
                MaxIdleTimeoutPercent=1.0



                org.jboss.resource.security.ManyToOnePrincipalMapping


                userName=sa
                password=


                -->

                <!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->

                JmsXA
                JCA:service=RARDeployer
                JMS Adapter
                MinervaXACMFactory
                <!-- See the documentation for the specific connection manager
                implementation you are using for the properties you can set -->

                # Pool type - uncomment to force, otherwise it is the default
                #PoolConfiguration=per-factory

                # Connection pooling properties - see
                # org.jboss.pool.PoolParameters
                MinSize=0
                MaxSize=10
                Blocking=true
                GCEnabled=false
                IdleTimeoutEnabled=false
                InvalidateOnError=false
                TrackLastUsed=false
                GCIntervalMillis=120000
                GCMinIdleMillis=1200000
                IdleTimeoutMillis=1800000
                MaxIdleTimeoutPercent=1.0


                <!-- Principal mapping configuration -->
                org.jboss.resource.security.ManyToOnePrincipalMapping




                <!-- ==================================================================== -->
                <!-- Auto deployment -->
                <!-- ==================================================================== -->


                J2EE:service=J2eeDeployer;
                JCA:service=RARDeployer

                ../deploy,../deploy/lib


                <!-- ==================================================================== -->
                <!-- JMX adaptors -->
                <!-- ==================================================================== -->






                10

                8082


                <!-- ==================================================================== -->
                <!-- Mail Connection Factory -->
                <!-- ==================================================================== -->

                Mail
                mail.properties
                user_id
                password


                <!-- ==================================================================== -->
                <!-- Uncomment to enable JMX monitoring of the bean cache

                -->
                <!-- ==================================================================== -->

                <!-- ==================================================================== -->
                <!-- Scheduler Service -->
                <!-- ==================================================================== -->
                <!-- Uncomment this to enable Scheduling - ->











                <!- - -->

                <!-- ==================================================================== -->
                <!-- Add your custom MBeans here -->
                <!-- ==================================================================== -->