亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

收到錯誤消息“SQL 狀態:08001 找不到適合 jdbc:oracle:thin:

收到錯誤消息“SQL 狀態:08001 找不到適合 jdbc:oracle:thin:

胡子哥哥 2023-04-13 14:14:59
有人可以建議我在這里做錯了什么:獲取錯誤消息為“ SQL 狀態:08001 沒有找到適合 jdbc:oracle:thin:@128:23:44:01:12345:pppp_rr 的驅動程序 Picked up JAVA_TOOL_OPTIONS: -Duser.home=C:\Users\123ert ”import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;public class JDBCExample {    public static void main(String[] args) {        try (Connection conn = DriverManager.getConnection(                "jdbc:oracle:thin:@128:23:44:01:12345:pppp_rr", "Test123", "********")) {            if (conn != null) {                System.out.println("Connected to the database!");            } else {                System.out.println("Failed to make connection!");            }        } catch (SQLException e) {            System.err.format("SQL State: %s\n%s", e.getSQLState(), e.getMessage());        } catch (Exception e) {            e.printStackTrace();        }    }}
查看完整描述

1 回答

?
Qyouu

TA貢獻1786條經驗 獲得超11個贊

我無法使用 Oracle 數據庫對其進行準確測試,但我知道在建立連接之前必須注冊一個驅動程序。檢查以下代碼,這基本上是您的代碼加上驅動程序注冊。


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

    // registration for the driver, it's needed, 

    // otherwise there will be "no suitable driver found"

    Class.forName("oracle.jdbc.driver.OracleDriver");


    try (Connection conn = DriverManager.getConnection(

            "jdbc:oracle:thin:@128:23:44:01:12345:pppp_rr", "Test123", "********")) {


        if (conn != null) {

            System.out.println("Connected to the database!");

        } else {

            System.out.println("Failed to make connection!");

        }


    } catch (SQLException e) {

        System.err.format("SQL State: %s\n%s", e.getSQLState(), e.getMessage());

    } catch (Exception e) {

        e.printStackTrace();

    }

}


查看完整回答
反對 回復 2023-04-13
  • 1 回答
  • 0 關注
  • 231 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號