如何将ojdbc jar添加到我的项目并使用它 [英] How to add the ojdbc jar to my project and use it
问题描述
我有一个项目需要连接到oracle数据库,所以我有ojdbc jar文件和一个简单的项目。 / p>
try {
Class.forName(oracle.jdbc.driver.OracleDriver);
连接conn = DriverManager.getConnection(jdbc:oracle:thin:@+ this.host +:+ this.port +:+ this.db,this.user,this.pass);
语句stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(query);
while(rset.next())
{
retStr + = rset.getString(1)+',';
}
stmt.close();
conn.close();
}
我有一个例外, oracle.jdbc .driver.OracleDriver
不存在。
如何将jar添加到我的项目并使用它?
我做了这一步,我仍然得到例外。
您必须将jar添加到您的Classpath中。您可以通过右键单击项目 - >构建路径 - >配置构建路径
必须将jar添加到您的Classpath。您可以通过右键单击项目 - >构建路径 - >配置构建路径
在库选项卡下,单击添加Jars并给出Jar oracle jdbc驱动程序)。
Oracle JDBC驱动程序下载 here
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.
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?
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
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
Under Libraries tab, click Add Jars and give the Jar (oracle jdbc driver).
Oracle JDBC Driver download here
这篇关于如何将ojdbc jar添加到我的项目并使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!