Cheers Anthony
I was looking at that but needed confirmation.
Regards
john
----- Original Message -----
From: "anthony.dodd" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, June 11, 2002 5:08 AM
Subject: Re: JNDI lookup connection datasource microsoft sql server
> Hi
>
> I've posted a solution see "Generic DataSource Resource Factory
> Available. JDBC Data Source" on the tomcat user maillist. I used the
> datadirect ConnectJDBC as I found the Microsoft implementation was very
> poor. The Microsoft JDBC is just an older version of ConnectJDBC which
> datadirect felt was'nt going the right direction.
>
> Tony
>
> ----- Original Message -----
> From: "John McAuley" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, June 10, 2002 2:17 AM
> Subject: JNDI lookup connection datasource microsoft sql server
>
>
> Hi folks,
>
> I am trying to use Microsoft's jdbc driver for ms sql with Tomcat and
am
> running into trouble with the JNDI lookup method. I look for a datasource
> and get null. If I use the class.forname method the driver is found and
> works perfectly but I am unable to get it working with the JNDI look up,
> This is very frustrating and seems to crop up a couple of times with
fellow
> users. Any thoughts ??
>
> Help much appreciated.
>
> John
>
> Server.xml
>
> <Context path="/tools" docBase="tools" debug="0" reloadable="true">
> <Resource name="jdbc/ToolsDB" auth="Container"
> type="javax.sql.DataSource"/>
> <ResourceParams name="jdbc/ToolsDB">
> <parameter>
> <name>user</name>
> <value>user</value>
> </parameter>
> <parameter>
> <name>password</name>
> <value>password</value>
> </parameter>
> <parameter>
> <name>driverClassName</name>
>
> <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
> </parameter>
> <parameter>
> <name>driverName</name>
>
> <value>jdbc:microsoft:sqlserver://IP-ADDRESS-of-server:1433</value>
> </parameter>
> </ResourceParams>
> </Context>
>
> web.xml
>
> <resource-ref>
> <description>
> Resource reference to a factory for java.sql.Connection
> instances that may be used for talking to a particular
> database that is configured in the server.xml file.
> </description>
> <res-ref-name>
> jdbc/ToolsDB
> </res-ref-name>
> <res-type>
> javax.sql.DataSource
> </res-type>
> <res-auth>
> Container
> </res-auth>
> </resource-ref>
>
> Code Snippet
>
> Context ctx = new InitialContext();
> Context envCtx = (Context)ctx.lookup("java:comp/env");
> out.println("Got first context.");
>
> NamingEnumeration enum
> =ctx.listBindings("java:comp/env/jdbc");
> while( enum.hasMore() ) {
> out.println("Binding: " +
> ((Binding)enum.next()).toString() + "<br>");
> }
> DataSource ds =
> (DataSource)envCtx.lookup("jdbc/ToolsDB");
> out.println("Got the second context." + "<br>" +
> "<br>");
>
> if (ds != null)
> {
> out.println("Getting the connection from the
> context.");
> Connection connection = ds.getConnection();
> }else{
> out.println("not working");
> }
>
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>