**我的JDK:** 1.8.0.112發現JDBC沒有合適的驅動程序瘦:@localhost:1521:ORCL
**我的預言:** 11.2.0.2表達
* *我的IDE:** Intelij思想13
我的代碼:
包模型; import java.sql。*;
公共類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();
}
}
例外: 異常在線程 「主要」 值java.sql.SQLException:未發現JDBC合適的驅動程序:預言:瘦: @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)
如何解決缺失的依賴關係?我認爲在類路徑中缺少oracle jar。 –
爲什麼你的JDBC URL中有空格? –