tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean LeBlanc" <s...@nutros.com>
Subject MS Driver (again)
Date Mon, 03 Jun 2002 14:25:33 GMT
Has anyone gotten either the Beta 2 or the finalized driver to work via DataSource? I am getting
nowhere fast with this - does it even work? I *can* connect w/o using DataSource, but I'm
trying
to get database pooling working with Tomcat connecting to a MS SQL Server 2000 database, and
this seems like it should be a viable option. Thanks in advance.

Here is the relevant code snippet:

Context ctx = new InitialContext();
        Context envCtx = (Context)ctx.lookup("java:comp/env");
        System.out.println("Got first context.");

NamingEnumeration enum =ctx.listBindings("java:comp/env/jdbc");
   while( enum.hasMore() ) {
     System.out.println("Binding: " + ((Binding)enum.next()).toString() );
   }
        DataSource ds = (DataSource)envCtx.lookup("jdbc/nutrosDB");
        System.out.println("Got the second context.");

        if (ds != null)
        {
                System.out.println("Getting the connection from the context.");
                connection = ds.getConnection();
        }

==================================
DataSource is null. Here is the output:

Got first context.
Binding: nutrosDB: org.apache.naming.ResourceRef:Reference Class Name: javax.sql.DataSource
Type: scope
Content: Shareable
Type: auth
Content: Container
Type: user
Content: xxxx
Type: factory
Content: com.microsoft.jdbcx.sqlserver.SQLServerDataSourceFactory
Type: password
Content: xxxx
Type: url
Content: jdbc:microsoft:sqlserver://192.168.9.253;user=xxxx;Password=xxxx;DatabaseName=NutrosDev
Type: driverClassName
Content: com.microsoft.jdbc.sqlserver.SQLServerDriver
Type: database
Content: NutrosDev

Got the second context.
=====================================

Here is the server.xml snippet:
<Resource name="jdbc/nutrosDB" auth="Container"
                type="javax.sql.DataSource"/>
        <ResourceParams name="jdbc/nutrosDB">
        <parameter>
                <name>database</name><value>NutrosDev</value>
        </parameter>

        <parameter>
                <name>factory</name><value>com.microsoft.jdbcx.sqlserver.SQLServerDataSourceFactory</value>
        </parameter>


        <parameter>
                <name>driverClassName</name><value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
        </parameter>

        <parameter>
                <name>url</name><value>jdbc:microsoft:sqlserver://192.168.9.253;user=xxxx;Password=xxxx;DatabaseName=N
utrosDev</value>
        </parameter>

        <parameter>
                <name>user</name><value>xxxx</value>
        </parameter>
        <parameter>
                <name>password</name><value>xxxx</value>
        </parameter>
        </ResourceParams>

And the web.xml snippet:
<resource-env-ref>
        <description>test jdbc/nutrosDB</description>
        <resource-env-ref-name>jdbc/nutrosDB</resource-env-ref-name>
        <resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type>
</resource-env-ref>





--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message