tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean LeBlanc" <s...@nutros.com>
Subject RE: JNDI DataSource Problem: MS SQL Server
Date Wed, 17 Apr 2002 17:31:45 GMT


> -----Original Message-----
> From: Peter D Wilson [mailto:peter@dflora.com]
> Sent: Tuesday, April 16, 2002 9:19 PM
> To: Tomcat Users List
> Subject: JNDI DataSource Problem: MS SQL Server
>
>
> Could somebody provide jakarta-tomcat-4.0.3, server.xml +
> web.xml + java
> code,  working fragments similar to those that Eichfelder,
> Frank provided
> earlier today on this mail list. I am using MS SQL Server
> 6.5, where the
> direct DriverManager approach outside of Tomcat works perfectly.
>
> In the JNDI approach under Tomcat, I can list context, "jdbc"
> in context,
> "java:comp/env" and get my ResourceRef, "JobsDataSource" from
> the default
> context in server.xml listed, but I am unable to get a DataSource (or
> ConnectionPoolDataSource) returned.
>
> This is a very frustrating exercise!

Hi Peter,

I'm trying the same thing you are. Well, similar.
I'm using the Beta 2 version of Microsoft's JDBC driver to
connect to a SQL Server 2000 database. I'm not having much luck with it, though.
Any help you or anyone else can offer would be very much appreciated.

I tried putting this in my server.xml:

	  <Resource name="jdbc/nutrosDB" auth="Container"
                type="javax.sql.DataSource"/>
        <ResourceParams name="jdbc/nutrosDB">

        <parameter>
                <name>database</name><value>dbname</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>driverName</name><value>jdbc:microsoft:sqlserver://serverbox;user=user;Password=pwd;DatabaseName=dbname</value>
        </parameter>

        <parameter>
                <name>user</name><value>user</value>
        </parameter>

        <parameter>
                <name>password</name><value>password</value>
        </parameter>

        </ResourceParams>

And this in my web.xml:

<resource-ref>
        <description>test jdbc/nutrosDB</description>
        <res-ref-name>jdbc/nutrosDB</res-ref-name>
        <res-type>com.microsoft.jdbcx.sqlserver.SQLServerDataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

In my code, I am doing this:

Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
System.out.println(" About to get ds.");
com.microsoft.jdbcx.sqlserver.SQLServerDataSource ds =
(com.microsoft.jdbcx.sqlserver.SQLServerDataSource)envCtx.lookup("jdbc/nutrosDB");
System.out.println("About to get pooledconnection.");
PooledConnection x = ds.getPooledConnection("usr","pwd");
System.out.println("About to get connection.");
Connection conDB1 = x.getConnection();


This fails, and here is what is in the log file:

 About to get ds.
javax.naming.NamingException: Cannot create resource instance
        at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:167)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:299)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:834)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
        at Nutros.Beans.DatabaseBean.<init>(Unknown Source)
        at Nutros.Beans.beanBrand.loadProduct(Unknown Source)
        at org.apache.jsp.index$jsp._jspService(index$jsp.java:578)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java)
        at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
        at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
        at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
        at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
        at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
        at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
        at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
        at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
        at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
        at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
        at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
        at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
        at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
        at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
        at java.lang.Thread.run(Thread.java:479)


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message