繁体   English   中英

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

[英]Can't find Oracle Database Driver in Eclipse JAVA Program

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

我自己和另一位学生员工在过去的一天半里一直在努力解决这个问题,而且我们部门的其他人都没有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

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

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

我相信Oracle驱动程序类是: oracle.jdbc.OracleDriver

转到您的Web应用程序的deploy文件夹(C:\\ Program Files \\ Apache Software Foundation \\ Tomcat 6.0 \\ webapps),并确保存在ojdbc14.jar。

在相关文章中: 找不到Oracle jdbc驱动程序

解决了问题,在运行路径中添加了oracle库。 您是否也尝试过配置? (运行/运行配置选择您的配置/类路径选项卡)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM