gpt4 book ai didi

tomcat - 无法将 Java DB 与 ZK 框架一起使用 - 错误 : Cannot load JDBC driver class 'org.apache.derby.jdbc.ClientDriver'

转载 作者:行者123 更新时间:2023-11-28 22:36:15 26 4
gpt4 key购买 nike

我多次尝试在我的 Web 应用程序和 Derby 之间建立连接,但我在 eclipse 控制台中收到了这些错误消息:

INFO: Server startup in 3772 ms

ERROR: Cannot load JDBC driver class 'org.apache.derby.jdbc.ClientDriver'

ERROR: Cannot load JDBC driver class 'org.apache.derby.jdbc.ClientDriver'

11/02/2011 19:08:53 org.apache.catalina.core.StandardContext reload


My class and database definition is showed bellow:

// Obtain our environment naming context
javax.naming.Context initCtx = new InitialContext();

javax.naming.Context envCtx = (Context) initCtx.lookup("java:comp/env");


// Look up our data source by the name we gave it when we created it.
// In this case that's "jdbc/customer".
javax.sql.DataSource ds = (DataSource) envCtx.lookup("jdbc/customer");

conn = ds.getConnection();

And my web.xml and context are showed bellow.

in context.xml ...

Resource name="jdbc/customer"
auth="Container"
type="javax.sql.DataSource"
username="qwert"
password="asdf"
driverClassName="org.apache.derby.jdbc.ClientDriver"
url="jdbc:derby://localhost:1527/C:\\testes_db\\customer;create=true;"
maxActive="8"

and in the web.xml ...

res-ref-name jdbc/customer

res-type javax.sql.DataSource

res-auth Container


-- my second attempt

resource-env-ref-name jdbc/customer

resource-env-ref-type javax.sql.DataSource

我在 Windows 中使用 tomcat 6 和 eclipse wtp (europa)。我已经将 derby.jar 和 derbclinet.jar 放在 WEB_INF\lib 目录中......

我可以做些什么来解决这个问题?

谢谢!

最佳答案

由于您是在 context.xml 中配置数据源,因此是 Tomcat 管理它,而不是您的 webapp。

您必须将 JDBC 驱动程序 derbyclient.jar 放在 $TOMCAT_HOME/lib/目录中,而不是 yourwebapp/WEB-INF/lib/

关于tomcat - 无法将 Java DB 与 ZK 框架一起使用 - 错误 : Cannot load JDBC driver class 'org.apache.derby.jdbc.ClientDriver' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4974217/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com