tomcat 6.0 数据库连接池问题
我的数据库连接池总是报错:请那位好人帮我看看。先谢谢!!!org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at com.dao.BascDao.getCon(BascDao.java:27)
at com.dao.ShapeDao.getList(ShapeDao.java:20)
at com.servlet.PrintServlet.doGet(PrintServlet.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143)
... 18 more
我的tomcat C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib
中有数据驱动包 mssqljdbc2.jar文件也存在
我的web.xml中配置为:
<resource-ref>
<description>my/print</description>
<res-ref-name>my/print</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
</resource-ref>
我的C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf中的context.xml中是这样写的
<Resource
name="my/print"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="sa"
password="123456"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
utl="jdbc:sqlserver://localhost:1433;database=print"/>
连接类中:
public Connection getCon(){
try {
Context context=new InitialContext();
//Class.forName(driver);
//con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;database=print","sa","123456");
DataSource dat=(DataSource) context.lookup("java:comp/env/my/print");
con=dat.getConnection();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return con;
}