Thank you very much for your reply on Sunday.
The error is "Name jdbc is not bound in this Context" at ctx.lookup. In both
server.xml and web.xml, the type is
com.microsoft.jdbcx.sqlserver.SQLServerDataSource. Even I use the code:
  envCtx = (Context) initCtx.lookup("java:comp/env");
  ds = (ConnectionPoolDataSource ) envCtx.lookup("jdbc/daxin");
  if (ds != null){
        if(ds instanceof com.microsoft.jdbcx.sqlserver.SQLServerDataSource){
            SQLServerDataSource temp =
(com.microsoft.jdbcx.sqlserver.SQLServerDataSource)ds;
            con = temp.getPooledConnection("dzuo","dzuo").getConnection();

  I got the same error.  Besides jdbc, is there another name to use?
 I am using jdbc driver, why
com.microsoft.jdbc.sqlserver.SQLServerDriver.class in the mssqlserver.jar is
not indicated in the configuration? Why the driverClassName and the type are
the same? Does it related to MS sql server installation? I installed the MS
SQL JDBCdriver's servise pack 1 and 2. Does it have effect?
My current configuration is based on the link you sent me in the first
email:

Server.xml:
   ... ...
  <GlobalNamingResources>
    ... ...
        <Resource name="jdbc/dbName" auth="container"
type="com.microsoft.jdbcx.sqlserver.SQLServerDataSource" />
        <ResourceParams name="jdbc/dbName">
        <parameter>
        <name>factory</name>
        <value>com.microsoft.jdbcx.sqlserver.SQLServerDataSourceFactory</value>
        </parameter>
        <parameter>
                <name>driverClassName</name>
                <value>com.microsoft.jdbcx.sqlserver.SQLServerDataSource</value>
        </parameter>
     <parameter>
       <name>driverName</name><value>SQLServer</value>
     </parameter>

     <parameter><name>description</name><value>SQL Server
DataSource</value></parameter>

     <parameter><name>serverName</name><value>"daxin"</value></parameter>
     <parameter><name>portNumber</name><value>1433</value> </parameter>
    <parameter><name>selectMethod</name><value>cursor</value></parameter>
     <parameter><name>databaseName</name><value>pubs</value></parameter>
        <parameter><name>user</name><value>"dzuo"</value></parameter>
        <parameter><name>password</name><value>"dzuo"</value></parameter>
        </ResourceParams>
      ......
  </GlobalNamingResources>
   ... ...
   </Engine>
  </Service>
</Server>

web.xml:
  ....
  <resource-ref>
        <description>SQL Server DataSource</description>
        <res-ref-name>"jdbc/dbName"</res-ref-name>
        <res-type>com.microsoft.jdbc.sqlserver.SQLServerDataSource</res-type>
        <res-auth>Container</res-auth>
  </resource-ref>
</web-app>

Looking forward to more instruction.

-----Original Message-----
From: Parsons Technical Services [mailto:[EMAIL PROTECTED]
Sent: Sunday, May 02, 2004 4:07 PM
To: Tomcat Users List
Subject: Re: Please help on my DB pool problem --- I followed the
struction on the web


Try this code instead:

Context ctx = new InitialContext();
if (ctx == null) {
System.err.println("Conn.getConn ctx is null");
throw new Exception("Boom - No Context");
}
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/dbName");
if (ds != null)
connection = ds.getConnection();

I run this from a class. I have several util classes that handle my database
queries and thus in my jsps and servlets I simly call the util class with a
simple string. But we'll save that for another time.


As for the code in the web.xml, it is fine.

Doug


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to