Topic: 这是我在tomcat中sql server连接池的配置,麻烦各位大虾帮我看一下有什么问题

  Print this page

1.这是我在tomcat中sql server连接池的配置,麻烦各位大虾帮我看一下有什么问题 Copy to clipboard
Posted by: java8110
Posted on: 2004-02-17 12:33

这是我在tomcat中的配置,麻烦各位大虾帮我看一下有什么问题,多谢。
server.xml中的配置,我是用administration tool加上的
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/>
<Resource name="jdbc/mydb" type="javax.sql.DataSource"/>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
<ResourceParams name="jdbc/mydb">
<parameter>
<name>maxWait</name>
<value>50</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>password</name>
<value>mysql</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:microsoft:sqlserver://srx:1433;databasename=hotel</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>username</name>
<value>sa</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
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/mydb
</res-ref-name>
<res-type>
javax.sql.DataSource
</res-type>
<res-auth>
Container
</res-auth>
</resource-ref>
jsp页面的调用
<%
    Context initCtx = new InitialContext();
    Context envCtx = (Context) initCtx.lookup("java:comp/env");
    
    // Look up our data source
    DataSource ds = (DataSource)envCtx.lookup("jdbc/mydb");
    // Allocate and use a connection from the pool
    Connection conn = ds.getConnection();
%>
出现的错误
javax.servlet.ServletException: Cannot create JDBC driver of class '' for connect URL 'null', cause: null
  org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
  org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
  org.apache.jsp.index_jsp._jspService(index_jsp.java:69)
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

谢谢!

2.Re:这是我在tomcat中sql server连接池的配置,麻烦各位大虾帮我看一下有什么问题 [Re: java8110] Copy to clipboard
Posted by: java8110
Posted on: 2004-02-17 16:54

问题已经解决:)


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923