apache-tomcat-5.5.23配置oracle连接池错误,帮忙看一下。
HTTP Status 500 -
--------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Cannot create JDBC driver of class ' ' for connect URL 'null '
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:516)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:423)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class ' ' for connect URL 'null '
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
com.liubo.dao.WebADO.getConnection(WebADO.java:24)
com.liubo.action.WebAction.execute(WebAction.java:21)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.sql.SQLException: No suitable driver
java.sql.DriverManager.getDriver(DriverManager.java:243)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
com.liubo.dao.WebADO.getConnection(WebADO.java:24)
com.liubo.action.WebAction.execute(WebAction.java:21)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
--------------------------------------------
Apache Tomcat/5.5.23
[解决办法]
驱动的class没有定义,建议你在网上好好看看。我用的一个,可做为参考:
<data-sources>
<data-source key= "myajaxdb " type= "org.apache.commons.dbcp.BasicDataSource ">
<set-property property= "description " value= "Oracle DataSource " />
<set-property property= "driverClassName " value= "oracle.jdbc.driver.OracleDriver " />
<set-property property= "url " value= "jdbc:oracle:thin:@192.168.137.234:1521:jridc " />
<set-property property= "username " value= "idc_u_rs " />
<set-property property= "password " value= "idc " />
<set-property property= "minCount " value= "10 " />
<set-property property= "maxCount " value= "20 " />
<set-property property= "defaultAutoCommit " value= "false "/>
<set-property property= "defaultReadOnly " value= "false " />
<set-property property= "validationQuery " value= "SELECT 1 FROM DUAL " />
</data-source>
</data-sources>
[解决办法]
下载个ojdbc.jar放到你的web-inf/lib目录下
[解决办法]
你要配置数据库连接池吗 配置的server.xml 加在 </Host> 的上面
<Context path= "/db2test " docBase= "db2test "
reloadable= "true " crossContext= "true ">
<ResourceParams name= "jdbc/db2test ">
<parameter>
<name> maxWait </name>
<value> 5000 </value>
</parameter>
<parameter>
<name> maxActive </name>
<value> 6 </value>
</parameter>
<parameter>
<name> password </name>
<value> cgm </value>
</parameter>
<parameter>
<name> url </name>
<value> jdbc:oracle:thin:@127.0.0.1:1521:demo </value>
</parameter>
<parameter>
<name> driverClassName </name>
<value> oracle.jdbc.driver.OracleDriver </value>
</parameter>
<parameter>
<name> maxIdle </name>
<value> 2 </value>
</parameter>
<parameter>
<name> username </name>
<value> system </value>
</parameter>
</ResourceParams>
</Context>
获得Connection的代码
public class DB2JNDI {
public Connection getConnectin(){
Connection cn = null;
try{
Context ctx = new InitialContext();
System.out.println( "获得上下问对象 ");
DataSource ds = (DataSource) ctx.lookup( "java:comp/env/jdbc/test ");
System.out.println( "获得数据源 ");
cn = ds.getConnection();
System.out.println( "获得数据连接 ");
}catch(Exception e){
e.printStackTrace();
}
return cn;
}
}
在web.xml中加上放到 </web-app> 上面
<resource-ref >
<res-ref-name> jdbc/test </res-ref-name>
<res-type> javax.sql.DataSource </res-type>
<res-auth> Container </res-auth>
</resource-ref>
注意res-ref-name中间的值要与DataSource ds = (DataSource) ctx.lookup( "java:comp/env/jdbc/test ");这里的jdbc/test要一致
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html