首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >获取"java.sql.SQLException: Io异常:网络适配器无法建立连接“

获取"java.sql.SQLException: Io异常:网络适配器无法建立连接“
EN

Stack Overflow用户
提问于 2018-06-20 03:13:43
回答 1查看 290关注 0票数 0

下面是我的代码。我想从Oracle连接到Employee表。

代码语言:javascript
复制
public static void main(String[] args) {         
    try {
        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
        Connection connection = DriverManager.getConnection(
                    "jdbc:oracle:thin:@localhost:1521:orcl", "scott", "tiger");
        Statement statement = connection.createStatement();
        ResultSet resultset = statement.executeQuery("select 'Connected' from dual");
        resultset.next();
        String s = resultset.getString(1);
        System.out.println(s);
        statement.close();
        connection.close();
    } catch (Exception e) {
        System.out.println("The exception raised is:" + e);
    }
}

我总是得到这样的错误:“异常引发is:java.sql.SQLException: Io异常:网络适配器无法建立连接”

我试着关掉防火墙,但没成功。有没有人可以帮我解决这个问题。

EN

回答 1

Stack Overflow用户

发布于 2018-06-20 03:20:22

你试过远程登录那个数据库吗?就像..。

代码语言:javascript
复制
Telnet localhost 1521

只是为了检查是否有到该端口的进程列表。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50935464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档