在搜索之后我仍然无法使用oracle连接java我使用了以下程序。
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
public class LoadDriver{
public static void main(String[] args){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:scott/scott@localhost:1521:pdborcl");
}catch(SQLException e){
System.out.println(e.getMessage());
}catch(ClassNotFoundException e){
System.out.println("Class Not Found");
}
}
}
我收到了错误。
Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:pdborcl
因为getConnection抛出SQLException
我尝试了jdbc:oracle:thin:@localhost:1521:pdborcl
,scott
,pass
等所有方式,但仍然无法连接。任何人都可以帮忙连接吗?