JDBC连接Oracle问题:The network Adapter could not establish the connetion.

fancuixia 2004-04-08 05:09:00
JDBC连接Oracle问题:The network Adapter could not establish the connetion.

我查了资料,据说是因为Oracle是提供了MTS服务,导致此问题发生。
我看了Oracle中关于MTS的说明,可能必须提供MTS服务才行。是否有什么方法在不停止Oracle MTS 服务的情况下,用JDBC访问Oracle?

...全文
1043 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
fancuixia 2004-04-13
  • 打赏
  • 举报
回复
已经通过OCI连接方式连通数据库。
fancuixia 2004-04-09
  • 打赏
  • 举报
回复
试一下先
fancuixia 2004-04-09
  • 打赏
  • 举报
回复
From: Jon Haugsand <Jon-H.Haugsand@norges-bank.no>
Date: 19 Nov 2001 10:47:25 +0100
Message-ID: <m3u1vrhz2q.fsf_-_@norges-bank.no>
Subject: [suse-oracle] Jdbc thin driver problem solved (was: jdbc thin driver: connection refused


Short summary: If you have problems with connecting your NT client to
your Linux server using jdbc thin client, be sure that the server
machine name as known at the server exists at the client (and is the
same name).


Long story:


* Jon Haugsand
> To all who have tried to help me, thanks. I have now gotten some help
> from Oracle and though they could not find the cause of my problem,
> they found a way to live with it. (They suspect some bad
> configuration.) Here is a summary of the problem and the suggested
> cure, just in case others should struggle with the same problem.
>
> I have two Oracle servers, one Linux and one NT. I have two Oracle
> clients, one Linux and one NT. All in all, four machines
> interconnected through tcp/ip. Each client attempts to connect to
> each server using both standard protocol (?), e.g. using sqlplus and
> the jdbc thin driver, all in all I have 8 connection scenarios.
>
> Oracle on Linux is 8.1.7 (both server and client).
> Oracle on NT is 8.1.6 (both server and client).
> Several jdbc thin drivers are tested, including the latest downloaded
> from Oracle.
>
> Linux server NT server
> ------------------------------------------------------------
> Linux sqlplus OK OK
> Linux jdbc thin OK OK
> NT sqlplus OK OK
> NT jdbc thin fails OK
>
> Driver is oracle.jdbc.driver.OracleDriver
>
> The connection string used: jdbc:oracle:thin:@192.168.22.35:1521:ora8
>
> The NT jdbc thin client failed with:
> java.sql.SQLException: Io exception: The Network Adapter could
> not establish the connection
> at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
> at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
> at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:335)
> at
> oracle.jdbc.driver.OracleConnection.<init>
> (OracleConnection.java:361) at
> oracle.jdbc.driver.OracleDriver.getConnectionInstance
> (OracleDriver.java:442)
> at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:321)
> at java.sql.DriverManager.getConnection(DriverManager.java:517)
> at java.sql.DriverManager.getConnection(DriverManager.java:177)
> at Nytest.main(Nytest.java:54)
> java.lang.RuntimeException: SQL Exception Io exception:
> The Network Adapter could not establish the connection
> at Nytest.main(Nytest.java:70)
>
>
> Failed connection enters the listener which does not complain, but no
> activity is found on the server. (That is, I do not know how to
> measure such things. The trace and log files were almost, but not
> completely, empty and obscure.)
>
> A curious observation is that if I restart the listener at the Linux
> server, the NT jdbc thin client works for a few minutes, and then
> fails again.
>
> --------------------------------
> OK, then the CURE:
>
> The Oracle support suggested I use the following (white space free)
> connection string (structured here for readability):
>
> jdbc:oracle:thin:@(DESCRIPTION=
> (ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
> (HOST=192.168.22.35)
> (PORT=1521)))
> (CONNECT_DATA=(INSTANCE_NAME=ora8)
> (SERVICE_NAME=sil2002.norges.bank.no)))
>
> Lo and behold, this works. Thanks again for all helpfullness on this
> email list.


(Just after I sent this information, I discovered something. The
following is a copy of what I sent to the Oracle team.)

I have now discovered what might be the cause of the problem, and
I suggest that you test this out, and eventually report this to the
network development folks in your company.


What have been the situation up to now is that the Linux server has
not been a part of the local DNS i our company. That is, the server
name (banklab3) was not known as such at the NT client. Therefore, I
had to use the IP address. However, the server itself, and the Linux
client, uses the /etc/hosts file to be able to map from number to name
and vica versa.


Today, we inserted the Linux server banklab3 into the local DNS server such
that the NT client now knows that banklab3 has the matching IP address.


Today we have no problems with using the jdbc thin client as we had before.


Can it be so that the Oracle server at the Linux machine does not
"feel comfortable" with numbers and maps the IP address to its name
and returns this to the client, which does not accept this because it
does not know anything about this name?


If so, this is ceratinly not a preferred behaviour of the server, who
should respect the clients view of the world. (I humbly still admit
that there may also be some configuration problems with our Linux
server that makes this really a complex multi cause problem.)

moroser 2004-04-08
  • 打赏
  • 举报
回复
可能是你的监听器没启动
步骤:oracle安装目录-----》BIN----》TNSLSNR 双击启动
试一下
hellion1234 2004-04-08
  • 打赏
  • 举报
回复
最好在hosts文件加上域名解析,例如:

database 192.168.2.2

然后你的url就可以这样:jdbc:oracle:thin:@database:1521:check_db
Arias 2004-04-08
  • 打赏
  • 举报
回复
我也遇到这个问题了 我在本机上(win)系统上调连接就 出现了
但是把文件放到数据库server上就没有问题了
fancuixia 2004-04-08
  • 打赏
  • 举报
回复
Oracle的SID为check_db。

如果URL为
jdbc:oracle:thin:@192.168.2.2:1521:dddddd

会报错:connection refused(......)。

如果 ID 地址错误,或端口错误,或SID为 check_db,也就是真正的SID,就报错:The network Adapter could not establish the connetion.

也就是我的连接是正常的。

同样的语句,连接Windows 2000上的Oracle没有问题,有问题的是安装在Linux服务器上的Oracle。

望不吝指教。
源码链接: https://pan.quark.cn/s/8ddf8a1c92f9 **libcurl用于获取大型文件**libcurl作为一个开源的C语言库,提供了一系列的API来处理与URL相关的任务,涵盖了HTTP、FTP、SMTP等多种网络协议的应用。在执行大型文件的下载操作时,libcurl展现出卓越的性能表现和高度的灵活性,能够高效地管理大文件传输过程,有效预防内存溢出及其他潜在问题。**libcurl的基础操作**libcurl的基础应用包括以下几个环节:1. **初始化**:需要借助`curl_global_init()`函数来启动libcurl的工作环境。2. **建立会话句柄**:通过`curl_easy_init()`函数创建一个会话句柄,该句柄将用于后续所有的操作流程。3. **配置选项**:运用`curl_easy_setopt()`函数来设定多种参数,例如目标URL、超时时间、重试次数以及数据写入的回调函数等。4. **执行请求**:调用`curl_easy_perform()`函数来实施下载操作。5. **释放资源**:使用`curl_easy_cleanup()`函数来释放已经占用的资源。**获取大型文件时的重要设置**1. **数据写入回调函数**:在处理大型文件下载时,通常不希望一次性将整个文件载入内存。可以配置`CURLOPT_WRITEFUNCTION`选项,指定一个回调函数来处理接收到的数据片段,这样libcurl在接收到数据时会调用该函数,使得我们可以按需将数据写入文件或缓冲区。2. **缓冲策略**:可以设定缓冲区的大小(比如,通过`CURLOPT_BUFFERSIZE`),来控制每次接收数据的数量,从而优化内存...

81,111

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧