3 Replies Latest reply on Jun 20, 2008 1:25 AM by jaikiran

    Problem with connecton pooling in JBOSS 4.2.2GA

    priyarao234

      many documents suggests that for connection pooling we neeed to modify the file named with standardjaws.xml or jaws.xml... in these files we need to set the and <type-mapping> elements.. bUt i didn't get these file in my JBoss instalation directory.... plz tell me how to configure connection pooling in jboss any help is appricated...

        • 1. Re: Problem with connecton pooling in JBOSS 4.2.2GA
          jaikiran

          Datasources are configured through -ds.xml files which are placed in the deploy folder for deploying. You can find some examples in %JBOSS_HOME%\server\docs\examples\jca folder.

          • 2. Re: Problem with connecton pooling in JBOSS 4.2.2GA
            priyarao234

            thankQ kiran 4 ur fast reply but, already i configured mysql-ds.xml filr as shown bellow..

            mysql-ds.xml


            <local-tx-datasource>
            <jndi-name>DefaultDS</jndi-name>
            <connection-url>jdbc:mysql://localhost:3306/jmsDB</connection-url>
            <driver-class>com.mysql.jdbc.Driver</driver-class>
            <user-name>root</user-name>
            root
            <max-pool-size>50</max-pool-size>
            <min-pool-size>10</min-pool-size>
            .....
            .....



            and as part of my progrm my code is as follows

            package com.v2.util;
            import java.sql.Connection;
            import java.sql.SQLException;
            import java.util.Hashtable;

            import javax.naming.Context;
            import javax.naming.InitialContext;
            import javax.naming.NamingException;
            import javax.sql.DataSource;

            public class DBConnFactory
            {
            static Connection con=null;
            @SuppressWarnings("unchecked")
            public static Connection getConnection() throws NamingException, SQLException
            {

            InitialContext ic = null;
            DataSource ds = null;
            Hashtable env = new Hashtable();

            env.put(Context.INITIAL_CONTEXT_FACTORY,
            "org.jnp.interfaces.NamingContextFactory");
            env.put(Context.URL_PKG_PREFIXES,
            "=org.jboss.naming:org.jnp.interfaces");
            env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
            ic = new InitialContext(env);
            ds=(DataSource)ic.lookup("java:/DefaultDS");
            con = ds.getConnection();

            return con;
            }
            public static void main(String[] args) {
            try {
            System.out.println("connection---"+ DBConnFactory.getConnection());
            } catch (NamingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            }
            }
            }



            But whole running my progrm it showing the following error


            javax.naming.NameNotFoundException: DefaultDS not bound
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
            at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
            at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
            at sun.rmi.transport.Transport$1.run(Transport.java:153)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
            at java.lang.Thread.run(Thread.java:595)
            at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
            at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
            at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
            at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
            at javax.naming.InitialContext.lookup(InitialContext.java:351)
            at com.v2.util.DBConnFactory.getConnection(DBConnFactory.java:28)
            at com.v2.util.DBConnFactory.main(DBConnFactory.java:35)


            now u tell me how can i cross this....


            • 3. Re: Problem with connecton pooling in JBOSS 4.2.2GA
              jaikiran

              You are looking up the datasource from a standalone java program. The java: namespace (to which the datasource is bound) will not be accessible from the standalone client. See this http://wiki.jboss.org/wiki/HowCanIAccessADataSourceFromAClient for more information