Java 如何将 ojdbc jar 添加到我的项目中并使用它
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3193849/
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
How to add the ojdbc jar to my project and use it
提问by Elad
I need some help with the eclipse.
我需要一些关于日食的帮助。
I have a project which need to connect to oracle databases so i have the ojdbc jar file and a simple project.
我有一个需要连接到 oracle 数据库的项目,所以我有 ojdbc jar 文件和一个简单的项目。
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@"+this.host+":"+this.port+":"+this.db,this.user,this.pass);
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(query);
while (rset.next())
{
retStr += rset.getString(1) + ',';
}
stmt.close();
conn.close();
}
and I got an exception that the oracle.jdbc.driver.OracleDriver
is not exists.
how do I add the jar to my project and use it?
我得到了一个oracle.jdbc.driver.OracleDriver
不存在的例外。如何将 jar 添加到我的项目中并使用它?
I did this step and I still get the exception. You will have to add the jar to your Classpath. You can do that in eclipse by right clicking on the Project --> Build Path --> Configure Build Path
我做了这一步,我仍然得到异常。您必须将 jar 添加到类路径中。您可以在 Eclipse 中通过右键单击项目 --> 构建路径 --> 配置构建路径来执行此操作
回答by bragboy
You will have to add the jar to your Classpath. You can do that in eclipse by right clicking on the Project --> Build Path --> Configure Build Path
您必须将 jar 添加到类路径中。您可以在 Eclipse 中通过右键单击项目 --> 构建路径 --> 配置构建路径来执行此操作
Under Libraries tab, click Add Jars and give the Jar (oracle jdbc driver).
在 Libraries 选项卡下,单击 Add Jars 并提供 Jar(oracle jdbc 驱动程序)。
Oracle JDBC Driver download here
Oracle JDBC 驱动程序在此处下载
回答by Carl Smotricz
In my Java projects, I create a /lib
directory at the same level as /src
and /bin
. I throw any library jars in there and then right-click on the .jar
file and do "Build Path | Add to Build Path."
在我的 Java 项目中,我创建了一个/lib
与/src
和相同级别的目录/bin
。我将所有库 jar 放入其中,然后右键单击该.jar
文件并执行“构建路径 | 添加到构建路径”。
回答by Elad
Ok. finally The solution is to add the jar file into the Web-Inf/lib directory because I have a Dynamic web application. Thank you all.
好的。最后解决方法是将jar文件添加到Web-Inf/lib目录中,因为我有一个动态的web应用程序。谢谢你们。
回答by Dayanand Gaur
To Add ojdbc14.jar file into the projectIn Eclipse under project folder->WEB-INF->lib then Right click lib folder-> Build Path->Configure Build Path->Under Libraries->Click on Add External Jars->Computer->Local Disk (C:)->oraclexe->app->oracle->product->10.2.0->server->jdbc->lib->now select ojdbc14.jar
将 ojdbc14.jar 文件添加到项目中在 Eclipse 下的项目文件夹->WEB-INF->lib 然后右键单击 lib 文件夹-> 构建路径->配置构建路径->在库下->单击添加外部罐->计算机->本地磁盘(C:)->oraclex->app->oracle->product->10.2.0->server->jdbc->lib->现在选择ojdbc14.jar
Directly the path is C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar
直接路径是C:\oraclex\app\oracle\product\10.2.0\server\jdbc\lib C:\oraclex\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar