eclipse tomcat db2-jdbc 数据源配置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2974658/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:48:18  来源:igfitidea点击:

tomcat db2-jdbc datasource configure

javaeclipsetomcatjdbcdb2

提问by Enrique San Martín

i'm trying to configure a datasource of an db2 database in tomcat (using eclipse as IDE), but i cant solve the problem, Tomcat trow me the following exception:

我正在尝试在 tomcat 中配置 db2 数据库的数据源(使用 eclipse 作为 IDE),但我无法解决问题,Tomcat 向我抛出以下异常:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.ibm.db2.jcc.DB2Driver'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
    at com.azurian.lce.usuarios.ConnectionManager.getConnection(ConnectionManager.java:65)
    at com.azurian.lce.usuarios.db2.UsuarioDAOImpl.autenticar(UsuarioDAOImpl.java:101)
    at com.azurian.lce.usuarios.UsuarioServiceImpl.autenticar(UsuarioServiceImpl.java:31)
    at com.azurian.lce.web.admin.actions.LoginAction.execute(LoginAction.java:49)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    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:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
    at java.net.URLClassLoader.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)
    ... 23 more

where i put the jdbc files of DB2? i try in every place (in the libraries of the project, in the lib folder of the tomcat install directory, in the WEB-INF/lib folder of the Dinamic Web Project, in the tomcat classpath in the eclipse "tomcat server" configuration an so far)

我把 DB2 的 jdbc 文件放在哪里?我在每个地方都尝试了(在项目的库中,在tomcat安装目录的lib文件夹中,在Dinamic Web项目的WEB-INF/lib文件夹中,在eclipse“tomcat server”配置中的tomcat类路径中迄今为止)

Regards

问候

ps.: I'm using:

ps.:我正在使用:

DB2 9.7 Tomcat 6 JDK 1.6 Eclipse Galileo

DB2 9.7 Tomcat 6 JDK 1.6 Eclipse Galileo

回答by BalusC

You need to put it outside Eclipse in the /libfolder of Tomcat or in any of the paths as specified in the shared.loaderor common.loaderproperties in /conf/catalina.properties. If it doesn't solve the problem, then it is not the right Tomcat instance you think Eclipse is using.

您需要将它放在 Eclipse 之外/lib的 Tomcat 文件夹中,shared.loader或者common.loader放在/conf/catalina.properties. 如果它不能解决问题,那么它不是您认为 Eclipse 使用的正确 Tomcat 实例。

If everything went well (dropping the JDBC driver in server's library), then you should see it show up in the [ProjectName]/Java Resources (src)/Libraries/[ServerName]listing in the Project Explorer.

如果一切顺利(将 JDBC 驱动程序放入服务器的库中),那么您应该会看到它显示在项目资源管理器的[ProjectName]/Java Resources (src)/Libraries/[ServerName]列表中。