java 连接oracle报错java.sql.SQLException: Listener refused the connection with the following error
代码为:Stringdriver="oracle.jdbc.driver.OracleDriver";Stringurl="jdbc:oracle:thin:@169.2...
代码为:
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.<init>(PhysicalConnection.java:490)
at oracle.jdbc.driver.T4CConnection.<init>(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) 展开
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.<init>(PhysicalConnection.java:490)
at oracle.jdbc.driver.T4CConnection.<init>(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) 展开
2个回答
展开全部
手上没oracle软件,不能帮你测试哦。
建议百度关键字:ORA-12514,会找到你需要的。
建议百度关键字:ORA-12514,会找到你需要的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
String url="jdbc:oracle:thin:@169.254.118.5:1521/orcl";
take this
String url="jdbc:oracle:thin:@169.254.118.5:1521:orcl";
更多追问追答
追问
大师,好像还是不行呢,报错变成这样 了
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505 了
追答
public class ConnectionTest {
static Connection conn;
static Statement stm;
static ResultSet rs;
static String driver = "oracle.jdbc.driver.OracleDriver";
static String url = "jdbc:oracle:thin:@127.0.0.1:1521:orcl";
public static void main(String[] args) {
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection(url, "scott",
"WaydeWang84293972");
stm = conn.createStatement();
//String sql = "create table test2(id NUMBER(6) not null)";
//ResultSet rs1 = stm.executeQuery(sql);
stm.executeUpdate("insert into test2 values(" + 3453 + ")");
stm.executeUpdate("insert into test2 values(" + 1234 + ")");
stm.executeUpdate("insert into test2 values(" + 2345 + ")");
stm.executeUpdate("insert into test2 values(" + 4567 + ")");
rs = stm.executeQuery("select * from test2");
while (rs.next()) {
System.out.println(rs.getInt("ID"));
}
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
你改成你的,如果还不可以,你就是oracle监听服务什么的出错了
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询