如何从另一个系统连接到Oracle DB [英] How to connect to an Oracle DB from another system

查看:279
本文介绍了如何从另一个系统连接到Oracle DB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的系统上安装了Oracle 11g,我可以使用简单的java程序连接到数据库。

I have installed Oracle 11g on my system and i am able to connect to database using simple java program.

ORACLE_USER = "user1"
ORACLE_PASSWORD = "user1"
ORACLE_HOST = "localhost"
ORACLE_SID = "ORCL"
ORACLE_PORT = "1521 "  

String connectionString = "jdbc:oracle:thin:@(description=(address=(host=" + ORACLE_HOST
                    + ")(protocol=tcp)(port=" + ORACLE_PORT + "))(connect_data=(sid=" + ORACLE_SID + ")))";
Connection connection = DriverManager.getConnection(connectionString, ORACLE_USER,ORACLE_PASSWORD);

现在,我想连接我的队友系统的数据库我可以ping这个系统。
上面代码中的唯一更改是

Now, I want to connect my team mates system's database(LAN network). I am able to ping that system. The Only change i did in above code is

ORACLE_HOST = "kdsystem" //machine name

但同一代码失败并显示以下错误讯息:

but same code fails and showing following error message:

java.sql.SQLException: Io exception: The Network Adapter could not establish the
 connection
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:112)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:146)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:255)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
            at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
    414)
......
....

请帮助我解决这个问题。
感谢。

Please help me to resolve this issue. Thanks.

推荐答案

在你的队友机器上,你可以检查netstat或其他工具,如果它正在侦听ORACLE_PORT和ORACLE_HOST(IP地址对您的计算机可见,或0.0.0.0)。你可以在Linux / unix机器上检查它:

On your team mate machine you can check with netstat or other tool if it is listening on ORACLE_PORT and on ORACLE_HOST (IP adress visible to your machine, or 0.0.0.0). You can check it on Linux/unix machine with:

netstat -an | grep 1521

或在Windows机器上 grep 不可用:

or on Windows machine where grep is not available:

netstat -an | findstr 1521

显示此命令的结果。

如果Oracle正在localhost(127.0.0.1)上侦听,则其他计算机无法与其进行连接。您必须将Oracle服务器配置为其他人可用的地址。

If Oracle is listening on localhost (127.0.0.1) then other machines cannot connect with it. You will have to configure Oracle server to address available to others.

如果Oracle正在侦听其他计算机可用的地址,请检查是否可以使用telnet连接到该计算机。如果它不能与Oracle连接,那么在这两台机器之间可能存在防火墙或类似的阻塞。

If Oracle is listening on address available to other machines, then check if you can connect to that machine using telnet. If it cannot connect with Oracle then probably there is firewall or similar blockade between those two machines.

这篇关于如何从另一个系统连接到Oracle DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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