java - Eclipse JAVA程序中找不到Oracle数据库驱动程序

标签 java eclipse oracle connection executable-jar

我正在尝试在 Eclipse 中连接到 Oracle 数据库。我在同一项目的 lib 文件夹中有 ojdbc14.jar,并将其添加到项目的构建路径中,因此它也驻留在引用的库目录中,但我仍然在控制台中得到“无法找到数据库驱动程序”的输出

我自己和另一位学生员工在过去的一天半里一直在努力解决这个问题,而且我们部门中没有其他人有 Java 和 JSP 经验,所以我认为 StackOverflow 将是我们最好的选择 =)

try {
            // Load the JDBC driver
            String driverName = "oracle.jdbc.driver.OracleDriver";
            System.out.println("Attempting to load the driver...");
            Class.forName(driverName);
            System.out.print("Loaded the driver");

            // Create a connection to the database
            String serverName = " ;) ";
            String portNumber = " ;) ";
            String sid = " ;) ";
            String url = "jdbc:oracle:thin:@" + serverName + ":"
                    + portNumber + ":" + sid;
            String username = "kenne13";
            String password = "**********";
            connection = DriverManager.getConnection(url, username, password);
            if (connection != null) {
                return true;
            }

        } catch (ClassNotFoundException e) {
            // Could not find the database driver
            System.out.println("Could not find the database driver");
            connected = false;
        } catch (SQLException e) {
            // Could not connect to the database
            System.out.println("Could not connect to the database");
            connected = false;
        }

这是控制台中的输出:

    Aug 18, 2011 10:07:50 AM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 382 ms
    Attempting to load the driver...
    Could not find the database driver

Here是代码、错误和我的项目目录的屏幕截图。

最佳答案

我现在非常确定驱动程序的类名称是 oracle.jdbc.OracleDriver 而不是 oracle.jdbc.driver.OracleDriver

关于java - Eclipse JAVA程序中找不到Oracle数据库驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7109144/

相关文章:

java - 无法加载类: com. mysql.jdbc.Driver

java - 将 CORBA orbd-Name 服务安装为 Windows 服务

java - 如何检查可能存在或不存在的元素的可见性?

eclipse - Eclipse 中突出显示的文本不可读

java - 有没有java的sqlldr api

java - 显示个别学生的分数

java - WAR 文件在 Tomcat 服务器中抛出 OutOfMemoryError

java - 在 IntelliJ IDEA 中突出显示异常抛出者

sql - 字符集不匹配oracle错误

php - PDO OCI8 2.0.0,在 centos linux 6.5 上编译时出错