You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sean LeBlanc <se...@nutros.com> on 2002/06/03 16:25:33 UTC

MS Driver (again)

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: MS Driver (again)

Posted by Sean LeBlanc <se...@nutros.com>.
Thanks for the help. I saw this before, but after giving it a closer
look I realized I needed to add the appropriate jars and use the dbcp
factory class. Now that it actually at last connects, what is the best
way to use this? I stress-tested a bit, and I started to get errors showing
up in the log that say this in the stack trace:

java.util.NoSuchElementException: Timeout waiting for idle object
        at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(Unknown Source)
        at org.apache.commons.dbcp.PoolingDataSource.getConnection(Unknown Source)
        at org.apache.commons.dbcp.BasicDataSource.getConnection(Unknown Source)

This is after the stress test has been running a few seconds. I suspect I'm not
using the DataSource and Connection correctly. Should I keep a Singleton that
holds one DataSource instance, and always use it to do getConnection? I tried that,
and seem to get the same results. Any help appreciated.



> -----Original Message-----
> From: Jacob Kjome [mailto:hoju@visi.com]
> Sent: Monday, June 03, 2002 9:25 AM
> To: Tomcat Users List; sean@nutros.com
> Subject: Re: MS Driver (again)
> 
> 
> Hello Sean,
> 
> See this email.  It has links to a few resources that tell about a
> proven way to use DBCP.
> 
> http://marc.theaimsgroup.com/?l=tomcat-user&m=102242646003357&w=2
> 
> Take a look at your parameters.  For instance, "user" should be
> "username".  Just check and double check that all your configuration
> is proper and matches up with an example that has been proven to work
> (link above).
> 
> Jake
> 
> Monday, June 03, 2002, 9:25:33 AM, you wrote:
> 
> SL> Has anyone gotten either the Beta 2 or the finalized 
> driver to work via DataSource? I am getting
> SL> nowhere fast with this - does it even work? I *can* 
> connect w/o using DataSource, but I'm trying
> SL> to get database pooling working with Tomcat connecting to 
> a MS SQL Server 2000 database, and
> SL> this seems like it should be a viable option. Thanks in advance.
> 
> SL> Here is the relevant code snippet:
> 
> SL> Context ctx = new InitialContext();
> SL>         Context envCtx = (Context)ctx.lookup("java:comp/env");
> SL>         System.out.println("Got first context.");
> 
> SL> NamingEnumeration enum =ctx.listBindings("java:comp/env/jdbc");
> SL>    while( enum.hasMore() ) {
> SL>      System.out.println("Binding: " + 
> ((Binding)enum.next()).toString() );
> SL>    }
> SL>         DataSource ds = 
> (DataSource)envCtx.lookup("jdbc/nutrosDB");
> SL>         System.out.println("Got the second context.");
> 
> SL>         if (ds != null)
> SL>         {
> SL>                 System.out.println("Getting the 
> connection from the context.");
> SL>                 connection = ds.getConnection();
> SL>         }
> 
> SL> ==================================
> SL> DataSource is null. Here is the output:
> 
> SL> Got first context.
> SL> Binding: nutrosDB: 
> org.apache.naming.ResourceRef:Reference Class Name: 
> javax.sql.DataSource
> SL> Type: scope
> SL> Content: Shareable
> SL> Type: auth
> SL> Content: Container
> SL> Type: user
> SL> Content: xxxx
> SL> Type: factory
> SL> Content: com.microsoft.jdbcx.sqlserver.SQLServerDataSourceFactory
> SL> Type: password
> SL> Content: xxxx
> SL> Type: url
> SL> Content: 
> jdbc:microsoft:sqlserver://192.168.9.253;user=xxxx;Password=xx
> xx;DatabaseName=NutrosDev
> SL> Type: driverClassName
> SL> Content: com.microsoft.jdbc.sqlserver.SQLServerDriver
> SL> Type: database
> SL> Content: NutrosDev
> 
> SL> Got the second context.
> SL> =====================================
> 
> SL> Here is the server.xml snippet:
> SL> <Resource name="jdbc/nutrosDB" auth="Container"
> SL>                 type="javax.sql.DataSource"/>
> SL>         <ResourceParams name="jdbc/nutrosDB">
> SL>         <parameter>
> SL>                 <name>database</name><value>NutrosDev</value>
> SL>         </parameter>
> 
> SL>         <parameter>
> SL>                 
> <name>factory</name><value>com.microsoft.jdbcx.sqlserver.SQLSe
> rverDataSourceFactory</value>
> SL>         </parameter>
> 
> 
> SL>         <parameter>
> SL>                 
> <name>driverClassName</name><value>com.microsoft.jdbc.sqlserve
> r.SQLServerDriver</value>
> SL>         </parameter>
> 
> SL>         <parameter>
> SL>                 
> <name>url</name><value>jdbc:microsoft:sqlserver://192.168.9.25
> 3;user=xxxx;Password=xxxx;DatabaseName=N
> SL> utrosDev</value>
> SL>         </parameter>
> 
> SL>         <parameter>
> SL>                 <name>user</name><value>xxxx</value>
> SL>         </parameter>
> SL>         <parameter>
> SL>                 <name>password</name><value>xxxx</value>
> SL>         </parameter>
> SL>         </ResourceParams>
> 
> SL> And the web.xml snippet:
> SL> <resource-env-ref>
> SL>         <description>test jdbc/nutrosDB</description>
> SL>         
> <resource-env-ref-name>jdbc/nutrosDB</resource-env-ref-name>
> SL>         
> <resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type>
> SL> </resource-env-ref>
> 
> 
> 
> 
> 
> SL> --
> SL> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> SL> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
> 
> 
> 
> -- 
> Best regards,
>  Jacob                            mailto:hoju@visi.com
> 
> 
> --
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
> 
> 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: MS Driver (again)

Posted by Jacob Kjome <ho...@visi.com>.
Hello Sean,

See this email.  It has links to a few resources that tell about a
proven way to use DBCP.

http://marc.theaimsgroup.com/?l=tomcat-user&m=102242646003357&w=2

Take a look at your parameters.  For instance, "user" should be
"username".  Just check and double check that all your configuration
is proper and matches up with an example that has been proven to work
(link above).

Jake

Monday, June 03, 2002, 9:25:33 AM, you wrote:

SL> Has anyone gotten either the Beta 2 or the finalized driver to work via DataSource? I am getting
SL> nowhere fast with this - does it even work? I *can* connect w/o using DataSource, but I'm trying
SL> to get database pooling working with Tomcat connecting to a MS SQL Server 2000 database, and
SL> this seems like it should be a viable option. Thanks in advance.

SL> Here is the relevant code snippet:

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

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

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

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

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

SL> Got the second context.
SL> =====================================

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

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


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

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

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

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





SL> --
SL> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
SL> For additional commands, e-mail: <ma...@jakarta.apache.org>



-- 
Best regards,
 Jacob                            mailto:hoju@visi.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>