书余 2020-10-19 19:41
浏览 39

连接PLSQL Developer 13 (64 bit)时拒绝lian'j

这个是连接数据库代码
package utli;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

import javax.swing.plaf.synth.SynthStyle;

public class Tool {

//获取与数据库的连接
public static Connection getConn() {
    Connection conn=null;
    try {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL", "scott", "123456");
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();


    }

    return conn;
}

//关闭数据库的连接
public static void close(Connection conn,PreparedStatement psmt) {
    try {
        if (conn!=null) {
            conn.close();
        }
        if (psmt!=null) {
            psmt.close();
        }
    } catch (Exception e) {
        // TODO: handle exception
    }

}
public static void main(String[] args) {
    Connection conn=Tool.getConn();

    if (conn!=null) {
        System.out.println("连接成功");
    }else {
        System.out.println("连接失败");
    }
}

}
报错信息
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:ORCL
这个怎么解决各位da'l

  • 写回答

0条回答 默认 最新

      报告相同问题?

      悬赏问题

      • ¥70 基于模糊控制的统一混沌控制器代码
      • ¥15 有没有精通光束整形的能读懂
      • ¥15 关于#STM32#与AMG8833采用双插值算法进行热成像显示不正常的问题,如何解决?
      • ¥15 求解! 头歌操作系统 课堂练习6.1 块设备访问
      • ¥15 comsol低温等离子体射流气体摩尔分数作为初始摩尔浓度参数输入到介质管出口流注无法推进了
      • ¥15 有没有人解答51的这个问题,如何解决?(关键词-数码管)
      • ¥15 python 爬虫问题
      • ¥15 求运用模拟退火算法寻优,以下是参考我的参考代码
      • ¥15 VB6.0中OptionButton不能赋值TextBox100
      • ¥15 主窗体激活keydown事件,但是阻塞了主线程