此Java代码编译罚款,但是当我尝试运行它,我得到:
异常在线程“主要”抛出java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDriver
这里是我的代码:
import java.sql.*;
public class TestConnection {
public static void main(String[] args) throws Exception {
//connect to database
Class.forName("oracle.jdbc.driver.OracleDriver");
String serverName = "000.000.000.000";
String portNumber = "1521";
String sid = "abcd";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "user";
String password = "pass";
Connection conn = DriverManager.getConnection(url, username, password);
}
}
我如何得到这个工作? 我使用Ubuntu 11.04和JDK 6。
谢谢!