gpt4 book ai didi

java - 找不到适用于 jdbc : oracle: thin:@localhost:1521:orcl 的合适驱动程序

转载 作者:行者123 更新时间:2023-12-01 09:05:20 26 4
gpt4 key购买 nike

**我的JDK:**1.8.0.112

**我的神谕:**11.2.0.2 Express

**我的 IDE:**Intelij Idea 13

我的代码:

封装型号;导入java.sql.*;

公共(public)类 PersonDA {

public static void main(String[] args)throws Exception {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection=DriverManager.getConnection("jdbc: oracle: thin:@localhost:1521:orcl","*****","********");
Statement statement= connection.createStatement();
ResultSet resultSet= statement.executeQuery("SELECT * FROM Person");

while ( resultSet.next()){

System.out.println(resultSet.getString("ID"));
System.out.println(resultSet.getString("name"));

}
statement.close();
connection.close();
}

}

异常(exception):线程“main”中出现异常 java.sql.SQLException: 没有找到适合 jdbc 的驱动程序: oracle: Thin:@localhost:1521:orcl

at java.sql.DriverManager.getConnection(DriverManager.java:689)

at java.sql.DriverManager.getConnection(DriverManager.java:247)

at model.PersonDA.main(PersonDA.java:8)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

最佳答案

更改您的网址:

"jdbc: oracle: thin:@//localhost:1521:orcl"

对此:

"jdbc:oracle:thin:@localhost:1521:orcl"

关于java - 找不到适用于 jdbc : oracle: thin:@localhost:1521:orcl 的合适驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41324508/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com