java 连接oracle报错java.sql.SQLException: Listener refused the connection with the following error代码为:String driver="oracle.jdbc.driver.OracleDriver";String url="jdbc:oracle:thin:@169.254.118.5:1521/orcl";String user="scott";String

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/03 08:02:14
java 连接oracle报错java.sql.SQLException: Listener refused the connection with the following error代码为:String driver=

java 连接oracle报错java.sql.SQLException: Listener refused the connection with the following error代码为:String driver="oracle.jdbc.driver.OracleDriver";String url="jdbc:oracle:thin:@169.254.118.5:1521/orcl";String user="scott";String
java 连接oracle报错java.sql.SQLException: Listener refused the connection with the following error
代码为:
String driver="oracle.jdbc.driver.OracleDriver";
String url="jdbc:oracle:thin:@169.254.118.5:1521/orcl";
String user="scott";
String password="tiger";
try {
Class.forName(driver);
Connection conn=DriverManager.getConnection(url, user, password);//此处即为最后一行中所提的15行
System.out.println("成功得到链接");
conn.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
报错信息为:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
The Connection descriptor used by the client was:
169.254.118.5:1521/orcl
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:110)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:171)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:496)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:411)
at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:490)
at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:202)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:465)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at maminjie.JDBC.访问数据库oracle.main(访问数据库oracle.java:15)

java 连接oracle报错java.sql.SQLException: Listener refused the connection with the following error代码为:String driver="oracle.jdbc.driver.OracleDriver";String url="jdbc:oracle:thin:@169.254.118.5:1521/orcl";String user="scott";String
String url="jdbc:oracle:thin:@169.254.118.5:1521/orcl";



take this
String url="jdbc:oracle:thin:@169.254.118.5:1521:orcl";