我安装了ojdbc14.jar,我试图用它编写基本连接:
import java.sql.*;
class OracleCon {
public static void main(String args[]) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe", "system", "oracle");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from emp");
while (rs.next())
System.out.println(rs.getInt(1) + " " + rs.getString(2) + " " + rs.getString(3));
con.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
但是当我运行它时,这个类是在编译时创建的。当我试图运行它时,出现错误。
错误:无法找到或加载主类oraclecon
有什么问题?