java.sql.SQLRecoverableException:网络适配器无法建立连接 [英] java.sql.SQLRecoverableException: The Network Adapter could not establish the connection

查看:1636
本文介绍了java.sql.SQLRecoverableException:网络适配器无法建立连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我正在使用的代码(Oracle数据库连接):

Here's the code I'm using (Oracle database connectivity):

try {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@loclahost:1521:XE","system","system");
        System.out.println("connection is established");
        Statement stmt=conn.createStatement();
        int i=stmt.executeUpdate("insert table students ( name varchar2(15),mobile number(10),age varchar2(1))");
        System.out.println("Save Sucessfully");
        stmt.close();
        conn.close();
} catch(Exception e) {
    System.out.println(e);
}
this.dispose();

出现以下错误:

java.sql.SQLRecoverableException:IO错误:网络适配器可能 无法建立连接

java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection

推荐答案

连接字符串中有错字-使用localhost代替loclahost

You've got a typo in your connection string - use localhost instead of loclahost

这篇关于java.sql.SQLRecoverableException:网络适配器无法建立连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆