简体   繁体   English

io 错误:网络适配器无法建立连接

[英]io error:network adapter could not establish the connection

I am developing a mini project using Java and Oracle XE database.我正在使用 Java 和 Oracle XE 数据库开发一个小型项目。 I was able to connect to database, insert, update and run all other queries from my personal computer, but when I tried to run the same program on my college computer (which is networked) it did not run and gave me the following exception message:我能够从我的个人计算机连接到数据库、插入、更新和运行所有其他查询,但是当我尝试在我的大学计算机(联网的)上运行相同的程序时,它没有运行并给了我以下异常消息:

io error:network adapter could not establish the connection

I tried researching the error message on the internet and found that it must be a firewall or port number problem, but I am unable to sort it.我尝试在互联网上研究错误信息,发现一定是防火墙或端口号问题,但我无法对其进行排序。 How can I fix this error?我该如何解决这个错误?

Here is the connection code that I used:这是我使用的连接代码:

public void connect()
{
    try
    {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","system");
    }
    catch(Exception e)
    {
        JOptionPane.showMessageDialog(this, e.getMessage());
    }
}

SimpleDateFormat sd=new SimpleDateFormat("dd-MM-yy");
DefaultTableModel table_allrec;
PreparedStatement pstmt,pstmt1;
Connection conn;
ResultSet rs,rs1;

This error is most likely caused by one of these factors: 此错误很可能是由以下因素之一引起的:

  • You are using the wrong URL 您使用的网址错误

  • The wrong port number or IP address (or DNS host name) was used 使用了错误的端口号或IP地址(或DNS主机名)

  • The listener is not configured properly 侦听器配置不正确

  • The listener process (service) is not running. 侦听器进程(服务)未运行。 You can re-start it with the "lsnrctl start" command or on Windows by starting the listener service. 您可以使用“ lsnrctl start”命令或在Windows上通过启动侦听器服务来重新启动它。

  1. Please make sure, you are entering correct username, password, hostname, PORT, SID while creating connection in SQL Developer请确保在 SQL Developer 中创建连接时输入正确的用户名、密码、主机名、端口、SID

  2. On the machine where DB is installed, go to this folder C:\\app{{Username_machine}}\\product\\11.2.0\\dbhome_1\\NETWORK\\ADMIN在安装了 DB 的机器上,进入这个文件夹 C:\\app{{Username_machine}}\\product\\11.2.0\\dbhome_1\\NETWORK\\ADMIN

PS : {{Username_machine}} : This is will differ from machine to machine PS : {{Username_machine}} : 这会因机器而异

  1. Open 2 files inside this listener.ora AND tnsnames.ora在此 listener.ora 和 tnsnames.ora 中打开 2 个文件

  2. Check hostname, PORT, SID mentioned in the files MUST match with the one you are trying to use in STEP 1.检查文件中提到的主机名、端口、SID 必须与您在步骤 1 中尝试使用的匹配。

  3. If any of the value doesn't match, Use the values present in the 2 Files for creating connection in SQL Developer如果任何值不匹配,请使用 2 个文件中存在的值在 SQL Developer 中创建连接

  4. Try to connect with updated values in case mismatch of values were found如果发现值不匹配,请尝试连接更新的值

  5. If you are still not able to connect如果您仍然无法连接

  6. press windows + R, and type services.msc -- this is will open Services running on your machine按 windows + R,然后键入 services.msc -- 这将打开在您的机器上运行的服务

  7. restart all the services that are starting with oracle重启所有以 oracle 启动的服务

  8. Try to reconnect again on SQL Developer尝试在 SQL Developer 上再次重新连接

  9. If it fails again,如果再次失败,

  10. Open CMD in administrative mode,在管理模式下打开CMD,

  11. Check if Your TNS Listener is up by typing the following command lsnrctl status通过键入以下命令 lsnrctl status 检查您的 TNS 侦听器是否已启动

  12. The above command will give error if the Listener is not up如果监听器没有启动,上面的命令会报错

  13. Start the Listener, by typing the following command, lsnrctl start启动监听器,输入以下命令,lsnrctl start

  14. In case you are having problems in starting your listener then try starting “OracleOraDb11g_home1TNSListener” windows service.如果您在启动侦听器时遇到问题,请尝试启动“OracleOraDb11g_home1TNSListener”Windows 服务。 For that open your Run Command and write services.msc this will open your service panel.为此,打开您的运行命令并编写 services.msc,这将打开您的服务面板。 Here search for the same and right click to start it.在这里搜索相同并右键单击以启动它。

  15. Doing the above steps, will resolve your Problem.执行上述步骤,将解决您的问题。 Thanks !谢谢 !

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IO 错误:网络适配器无法建立连接 - IO Error: The Network Adapter could not establish the connection 出现IO错误:网络适配器无法建立连接 - getting IO Error: The Network Adapter could not establish the connection Java:Io异常:网络适配器无法建立连接 - Java : Io exception: The Network Adapter could not establish the connection 无法创建 PoolableConnectionFactory(Io 异常:网络适配器无法建立连接) - Cannot create PoolableConnectionFactory (Io exception: The Network Adapter could not establish the connection) SQLException:Io异常:网络适配器无法建立连接 - SQLException: Io exception: The Network Adapter could not establish the connection 网络适​​配器无法建立连接 - The network adapter could not establish the connection IO 错误:将 oracle DB 作为 docker 容器运行时,网络适配器无法建立连接 - IO Error: The Network Adapter could not establish the connection when running oracle DB as docker container 获取'java.sql.SQLRecoverableException:IO错误:网络适配器无法建立连接',同时连接oracle数据库 - Getting 'java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection' while connecting oracle database sqldeveloper错误信息:网络适配器无法建立连接错误 - sqldeveloper error message: Network adapter could not establish the connection error 网络适​​配器无法建立连接错误,但telnet可以工作 - The Network Adapter could not establish the connection error but telnet works
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM