To establish an Oracle thin JDBC connection to a TNS alias (tnsname), make sure you pass the oracle.net.tns_admin system property to the JVM. Its value should be the directory in which your tnsnames.ora file is located. After that, you can just pass the TNS alias in place of the host name in the JDBC URL.
E.g. if you simply try to connect to jdbc:oracle:thin:@MYDB, which is in your tnsnames.ora file, you’ll get an SQLException with a detail message of Io exception: Unknown host specified. If you fire up the JVM with a -Doracle.net.tns_admin=/oracle/10g/NETWORK/ADMIN, or use System.setProperty(String,String) after startup, the connection will be established successfully.
Oh yeah? Well what’s this SQLException “Io exception: SO Exception was generated“, then? you ask? The exception message is a bit deceptive, as the “SO” suggests OCI when we’re really using thin. I encountered this exception with the ojdbc14.jar included with OC4J standalone 10.1.3.1.0. Using the JDBC driver from the Oracle client 10.2 package stops it occuring, but causes OC4J standalone to log a warning about a missing getStatistics method every few seconds, which is hardly any less annoying. I’m not sure what’s causing it to happen, but a version upgrade seems to fix it. If that’s not an option, you can always use good old jdbc:oracle:thin:@host:port/service, which is what I settled for in the end.
分享到:
相关推荐
通过oracle jdbc thin 驱动连接oracle数据库的客户端程序,在连接中应用了SSL、钱包、双向认证、Secure External Password Store tns配置等技术,完全实战代码,非常有参考价值。
如何正确oracle配置tnsname.ora文件
oracle配置文件tnsname.ora listener.ora sqlnet.ora
oracle中tnsname的配置,可以直接用,改好自己对应的ip
在RAC环境中,同一会话,当前会话连接节点实例故障,可以快速的切替的另一节中运行,对客户端的是完全透明的。
1234 SolutionRecommendations for protecting against this vulnerability can be found at:My Oracle Support Note 1340831.1 for Oracle Database deployments that use Oracle Real Application Clusters (RAC)....
Oracle数据库监听器(LISTENER)和本地服务名(Tnsname)配置.docx
oracleTNS报错oracleTNS报错oracleTNS报错
ORACLE数据库-TNS协议分析详解ORACLE数据库-TNS协议分析详解ORACLE数据库-TNS协议分析详解ORACLE数据库-TNS协议分析详解
oracle TNS配置oracle TNS配置oracle TNS配置
oracle 的 orcl TNS,是oracle自带的TNS,丢失的可以及时找回
Oracle数据库-TNS连接 第一份工作是在东亚银行,规定要穿正装上班,当时身上没有什么钱,只能去地摊上买黑裤子搭白衬衫,不忍直视。 进入项目组,第一件事就是给电脑安装Oracle客户端和PL/SQL。就如同你的钱存在银行...
BLOG_【故障处理】Oracle_lhr_TNS-12518、TNS-00517和 Linux Error:32:Broken pipe.pdfBLOG_【故障处理】Oracle_lhr_TNS-12518、TNS-00517和 Linux Error:32:Broken pipe.pdf
oracle TNS配置方法 大家可以仿照里面来进行配置
面向Oracle的,免安装的,配置tnsname和odbc驱动的工具包,base包可以直接解压配置tns_admin使用,ODBC需要管理员命令行安装下:进入目录,直接odbc_install.exe,运行。
oracle tns 配置文件 按这样配置一定行的 oracle tns 很吹若的东西
ORACLE-TNS协议分析详解 文档,具体1 TNS介绍,2 TNS数据格式 3 典型的使用序列 三个部分
测试ojdbc包及TNS串是否能正确连接数据库,测试java版本与jdbc包的兼容性
Oracle_TNS浅析.。对刚开始接触不太理解的比较适用
listener-tnsnamelistener-tnsnamelistener-tnsnamelistener-tnsnamelistener-tnsnamelistener-tnsnamelistener-tnsnamelistener-tnsname