简体   繁体   English

找不到适合 jdcb 的驱动程序

[英]No suitable driver found for jdcb

This is my first time doing sql work in Java, all I was doing was making a simple program where I open and close the connection这是我第一次用 Java 做 sql 工作,我所做的只是制作一个简单的程序,在其中打开和关闭连接

package exercises;

import java.sql.*;

public class JdbcEx1 {
    static Connection conn = null;
    static String dbURL = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
    static String user = "labs";
    static String password = "labs";

    public JdbcEx1() {}

    public static void main (String args[]) throws SQLException {

        try{
            Class.forName("oracle.jdbc.driver.OracleDriver");
        } catch (ClassNotFoundException e){
            System.err.println(e.getMessage());
        }

        try {
            conn = DriverManager.getConnection(dbURL, user, password);
            conn.clearWarnings();
            System.out.println("Connection opened! for driver ==>Oracle 11XE");
        } catch (SQLException e) {
            System.err.println(e.getMessage());
        } finally {
            if(!conn.isClosed()) {
                conn.close();
                System.out.println("Connection Close! Oracle");
            }
        }

    }
}

Whenever I try to run it I get the following error:每当我尝试运行它时,都会出现以下错误:

oracle.jdbc.driver.OracleDriver No suitable driver found for jdbc:oracle:thin:@127.0.0.1:1521:XE oracle.jdbc.driver.OracleDriver 未找到适合 jdbc:oracle:thin:@127.0.0.1:1521:XE 的驱动程序

I really don't have much of a clue as to whats going on, I've tried running through it with the debugger multiple times but that just confused me even more我真的不知道发生了什么,我试过用调试器多次运行它,但这让我更加困惑

The path of the ojdbc6.jar file that you points out:您指出的ojdbc6.jar文件的路径:

C:\\Program Files\\Java\\jre1.8.0_60\\lib\\ext , C:\\Program Files\\Java\\jre1.8.0_60\\lib\\ext

must be specified into the environment variable CLASSPATH .必须在环境变量CLASSPATH指定。

You need to have the ojdbc6.jar in your classpath environment variable in order to have JDBC 4.0 standard support.您需要在类路径环境变量中包含 ojdbc6.jar 才能获得 JDBC 4.0 标准支持。

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

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