[英]Java Program compile and run in command prompt successfully but not in myeclips?
I'm learning jdbc and working with Oracle database by writing this simple code.我正在通过编写这个简单的代码来学习 jdbc 并使用 Oracle 数据库。 The IDE i'm using is MyEclips.
我使用的 IDE 是 MyEclips。 But the problem is when I compile and run this program in command prompt it works properly but when I try to compile and run this program in my IDE ie MyEclips it through an error message:
但问题是当我在命令提示符下编译和运行这个程序时它可以正常工作,但是当我尝试在我的 IDE 中编译和运行这个程序时,即 MyEclips 通过一条错误消息:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
import java.sql.*;
class OracleCon{
public static void main(String args[])
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = null;
String URL = "jdbc:oracle:thin:@localhost:1521:xe";
String UN = "HR";
String PASS = "12345";
con = DriverManager.getConnection(URL,UN,PASS);
Statement stmt = con.createStatement();
String sql = "SELECT * FROM EMPLOYEES";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next())
{
System.out.println(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3));
}
}
catch (Exception e)
{
System.out.println(e);
}
}
}
I also set the class path in Environment variable.我还在环境变量中设置了类路径。 Environment variable snippet
环境变量片段
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.