1 2 Previous Next 20 Replies Latest reply on Mar 8, 2002 12:29 AM by luckystar_007 Go to original post
      • 15. Re: Help for lookup Datasource
        shink

        I changed my web.xml to simple :
        <?xml version="1.0" encoding="ISO-8859-1"?>
        <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
        <web-app>
        <resource-ref>
        The default DS
        <res-ref-name>jdbc/SQLServerPool</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        </resource-ref>
        </web-app>

        Then there is no mistake happened,I use this in my servlet test:

        Properties h = new Properties();
        ...
        InitialContext initCtx = new InitialContext(h);
        out.println("got context");
        javax.sql.DataSource ds = null;
        ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/SQLServerPool");
        if(ds==null)out.println("ds is null");
        ....

        it just stop for "ds is null".
        I use tomcat 4.0 and Jboss 2.4 and had done all the things as metioned by up you kind friends.
        So what's the problem?
        Thanks
        shink



        • 16. Re: Help for lookup Datasource
          tclouser

          shink,

          What do you have in your jboss-web.xml?

          TC

          • 17. Re: Help for lookup Datasource
            shink

            tclouser,
            As you said my jboss-web.xml is as follow:
            <?xml version="1.0" encoding="UTF-8"?>
            <jboss-web>
            <resource-ref>
            <res-ref-name>jdbc/SQLServerPool</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <jndi-name>java:/SQLServerPool</jndi-name>
            </resource-ref>
            </jboss-web>

            I don't deploy any EJB in Jboss,is that reason I can't use datasoure in servlet?



            • 18. Re: How about stand alone application, Help for lookup Datas
              luckystar_007

              tclouser had said that:

              >I believe the "java:" subcontext is only available to the containers and not to applications accessing the "global" context [but don't quote me on that

              I also found that on http://localhost:8082, the datasource jndi name is really on "java:",
              if so, how can I lookup the datasource from a standalone application?Who can help?very appreciated.

              • 19. Re: How about stand alone application, Help for lookup Datas
                davidjencks

                As stated so many times, you can't, and why on earth would you want to. If it worked, you would have introduced hidden distribution into your app, and would now require 2 extra between vm hops on every db access and/or every tx being distributed, thus requiring xa drivers. Use a reasonably layered architecture, as strongly encouraged by the j2ee model.

                • 20. Re: Can standalone application use connection pool in jboss?
                  luckystar_007

                  IPO zeng :
                  As you said that the datasource jndi name is not in global jndi namespace, then
                  How you will change you program to make it work?
                  Thanks!

                  1 2 Previous Next