从Java获取derby数据库连接(在eclipse中) [英] Getting derby database connection from Java (in eclipse)

查看:762
本文介绍了从Java获取derby数据库连接(在eclipse中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循以下说明:

http://www.eclipse.org/articles/article.php?file=Article-EclipseDbWebapps/index.html

为了设置derby数据库服务器,一切正常。我创建了数据库,可以轻松访问它。但是,这些指令使用JSP访问我的数据库和我的魔杖来更改它,以便我可以通过我的自定义Java类访问数据库,但我无法创建任何与数据库的连接。我只是试过:

in order to set-up a derby database server and everything works fine. I created the DB and could easily access it. however, these instructions use JSP to access my DB and I wand to change it so that I can access the DB through my custom Java classes but I cant create any connections to the DB. I simply tried:

Connection con = DriverManager.getConnection
    ("jdbc:derby://localhost:1527/features", "root", "root");

注意:这里我的数据库是名称功能

Note: here my DB is names features

我收到错误:

java.sql.SQLException: 
No suitable driver found for jdbc:derby://localhost:1527/features

我尝试加载驱动程序的类:

I tried loading the class for the driver:

Class.forName("org.apache.derby.jdbc.ClientDriver");

我收到错误:

java.lang.ClassNotFoundException: 
    org.apache.derby.jdbc.ClientDriver

我不知道在哪里找到并放置 org.apache.derby.jdbc.ClientDriver 。如何在说明中只添加META_INF下的 context.xml ,一切正常?我错过了什么?

I dont know where to find and put org.apache.derby.jdbc.ClientDriver. How come in the instructions they only add a context.xml under META_INF and everything work? What am I missing?

推荐答案

你有没有:


将文件derbyclient.jar从该文件夹复制到您的TOMCAT_ROOT / lib
文件夹(如果您使用的是Tomcat 5.x,请安装到
TOMCAT_ROOT / common / lib)。这会将Derby JDBC驱动程序安装到
Tomcat中,以便在DataSource中使用。

Copy the file derbyclient.jar from that folder to your TOMCAT_ROOT/lib folder (if you're using Tomcat 5.x, install into TOMCAT_ROOT/common/lib). This installs the Derby JDBC driver into Tomcat for use in a DataSource.

您需要在类路径中使用derbyclient.jar 。

You need the derbyclient.jar in the classpath.

这篇关于从Java获取derby数据库连接(在eclipse中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆