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?

...全文
1002 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。

望不吝指教。
1. AccountsTester(账户测试) 1.1 Select Account Type(选择账户类型) 1.2 Get By Type(通过类型获得) 1.3 Get All(显示全部) 1.4 Add(增加用户) 1.4.1 可以简单的几个步骤配置一个交换用户(email地址和密码) 1.5 Properties(属性) 1.6 features(特征) 1.7 authtoken type(用户标志类型) 2.Bad Behavior(屏蔽垃圾发布器) 2.1 Crash the main app thread(破坏主要的应用程序线程) 2.2 Crash an auxiliary app thread(破坏一个辅助应用程序线程) 2.3 Crash the native process(破坏本地进程) 2.4 Crash the system server(破坏系统服务器) 2.5 Report a WTF condition(????) 2.6 ANR(Application Not Responding)(Stop responding for 20 seconds)——(应用无响应)(停止反应20s) 2.7 ANR starting an Activity(运行一个活动,但是应用无相应) 2.8 ANR recriving a broadcast Intent(接收一个广播意图,但是应用无响应) 2.9 ANR staring a Service(运行一个服务,但是应用无响应) 2.10 System ANR(in ActivityManager(系统无响应)(在行为控制器上) 2.11 Wedge system(5 minutes system ANR)(楔板系统)(5分钟系统无响应) 3.configuration(配置) configuration 3.1 fontScale=1.0(缩放比例=1.0) 3.2 hardKeyboardHidden=2(隐藏硬件键盘=2) 3.3 keyboard=2(键盘=2) 3.4 locale=en_US(现场环境=英文) 3.5 mcc=310(电机控制中心=310???)(MOTOR CONTROL CENTER) 3.6 mnc=260(位技术控=260)(Microcomputer Numberical Control) 3.7 navigation=3(导航=3) 3.8 navigationHidden=1(隐藏导航=1) 3.9 orientation=1(定位=1) 3.10 screenLayout=0x22(屏幕格式=0x22) 3.11 touchscreen=3(触摸屏=3) 3.12 uiMode=0x11(用户界面模式=0x11) DisplayMetrics(不显示的属性) 3.13 density=1.5(密度=1.5) 3.14 densityDpi=240(密度分辨率=240) 3.15 heightPixels=800(高度像素=800) 3.16 scaledDensity=1.5(尺度密度=1.5) 3.17 widthPixels=480(宽度分辨率=480) 3.18 xdpi=240.0(x轴分辨率=240.0) 3.19 ydpi=240.0(y轴分辨率=240.0) 4.Connectivity(连接工具) 4.1 Enable Wifi(启动Wifi) 4.2 Disable Wifi(关闭Wifi) 4.3 Start Wifi Toggle(启动Wifi开关) 4.4 Stop Wifi Toggle(关闭Wifi开关) 4.5 Wifi on(ms)(Wifi开启多长时间) 4.6 Wifi off(ms)(Wifi关闭多长时间) 4.7 Cycles done:1(周期做一次) 4.7.1 Start Screen Toggle(启动屏幕开关) 4.7.2 Stop Screen Toggle(关闭屏幕开关) 4.7.3 Wifi on(ms)(Wifi开启多长时间) 4.7.4 Wifi off(ms)(Wifi关闭多长时间) 4.8 Cycles done:0(周期做0次) 4.8.1 Start MMS(开启彩信) 4.8.2 Stop MMS(关闭彩信) 4.8.3 Start HiPri(开启导航) 4.8.4 Stop HiPri(关闭导航) 5.Development Settings(开发设置) 5.1 Debug App(调试程序) Android 键盘/Android 系统/API Domes/Certificate Installer(证书安装)/com.android.gestuer.builder()/com.android.sdksetup()/Custom Locale()/Dev Tools(开发工具)/Example Wallpapers(墙纸式样)/HTML查看器/Live Wallpaper Picker(动态壁纸选取)/NetSpeed(网速)/OpenWnn(一种输入法)/Pico TTS(语音程序)/Sample Soft Keyboard(样品软键盘)/sdk2.3/Spare Parts(备件)/Speech Recorder(演讲录音机)/Status Bar(状态栏)/Terminal Emulator(终端模拟器)/TTS Service(TTS服务)/User Dictionary(用户词典)/拨号器/拨号器存储/打包安装程序/发送电子邮件/谷歌拼音输入法/后备/计算器/联系人存储/浏览器/录音机/媒体存放/启动器/软件包访问帮助程序/设置/设置存储/时钟/受DRM保护的内容的存储/搜索/搜索应用程序提供商/通讯录/下载管理器/下载内容/相机/信息/虚拟专用网服务/音乐/账户与同步设置/住屏幕提示 5.2 Wait for debugger(等待调试程序) 5.3 pointer location(触点位置) 5.4 show running processes(显示运行的程序) 5.5 show screen updates(显示屏幕更新) 5.6 Disable compatibility mode(禁用兼容性模式) 5.7 app process limit(应用程序限制) 5.8 immediately destroy activities(立即毁坏项目) 5.9 show cpu usage(显示CPU的进程) 5.10 show sleep state on LED(再LED上显示睡眠时间) 5.11 window animation scale 1x(窗口动画规模1X) 5.12 transition animation scale 1x(转换动画模式1X) 5.13 Light Hinting(轻显示) 5.14 show gtalk service connetion status(显示即时通讯连接标志) 6.goole login service(谷歌登录服务) 7.Instrumentation(仪表) 7.1 local sample(本地例子) 8. Media Scanner(媒体扫描仪) 9. Package Browser(包浏览器) 目录参照5.1 例如:Android键盘 Package Summary(包装总结) a. com.android.inputmethod.latin(来源网站) d. Restart(重启) b. (No Application Class)(无应用类型) c. (NO Label)(无标签) e. system(系统) f. process(程序) com.android.inputmethod.latin g. User ID(用户帐号) 10016 h. Task Affinity(任务类同) "com.android.inputmethod.latin" i. Version(版本) 2.3.1(#9) j. Source(资源) /system/app/LatinIME.apk k. Data(数据) /data/data/com.android.inputmethod.latin l. Activities(活动) LatinIMESettings/LatinIMEDebugSettings/InputLanguageSelection 例如:LatinIMESettings“android键盘设置” Multiple(normal):倍数(正常的) Process(程序) com.android.inputmethod.latin Task Affinity(任务类同) com.android.inputmethod.latin Required Permission(许可要求) (none) Multiprocess(多处理器) No Clear on Background(在背景中清理) No State Not Needed(国家不需要) No m. Services(服务) LatinIME(android键盘) 10. Pointer Location(触点的坐标位置) P:0(左键松开)/0(没有触点屏幕);X和Y(复位值):绝对值的dx为横向的绝对长度,正号代表从左向右触摸,负号正好相反。dy的绝对值代表纵向的绝对长度,正号代表从上往下触摸,负号正好相反;Xv和Yv:表示红线的横向和纵向相对长度,正负号的意思和X和Y一样;Prs:是否有点击屏幕;Size:线的尺寸(只显示一种) 11.Running processes(正在运行的程序) 例如:system process Information(程序信息) Process Name:(程序的名字) system(系统) package in process:(在程序中的包文件) android com.android.providers.settings 12. Sync Tester(同步测试) 12.1 Registered Sync Adapters:(注册同步适配器) 12.2 选择网站 12.3 bind(捆绑):点击显示:a.已经连接到同步适配器.b.连接资源地址:。。。c.账户类型:。。。 unbind(不捆绑);start sync(开始同步) cancel sync(取消同步)。 13. Terminal Emulator(终端模拟器)

81,115

社区成员

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

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