Oracle JDBC 连接在 Solaris 中出现异常,但在 Windows 中没有?

发布于 2024-08-26 19:18:23 字数 3955 浏览 7 评论 0原文

我有一些使用 DriverManager.getConnection() 连接到 Oracle 数据库的 Java 代码。它在我的 Windows XP 机器上运行得很好。但是,当在 Solaris 计算机上运行相同的代码时,出现以下异常。两台机器都可以访问网络上的数据库机器。我已经包含了 Oracle 跟踪日志。

Mar 23, 2010 12:12:33 PM org.apache.commons.configuration.ConfigurationUtils locate
FINE: ConfigurationUtils.locate(): base is /users/theUser/ADCompare, name is props.txt
Mar 23, 2010 12:12:33 PM org.apache.commons.configuration.ConfigurationUtils locate
FINE: Loading configuration from the path /users/theUser/ADCompare/props.txt
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.OracleDriver connect
FINE: OracleDriver.connect(url=jdbc:oracle:thin:@//theServer:1521/theService, info)
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.OracleDriver connect
FINER: OracleDriver.connect() walletLocation:(null)
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.OracleDriver parseUrl
FINER: OracleDriver.parseUrl(url=jdbc:oracle:thin:@//theServer:1521/theService)
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.OracleDriver parseUrl
FINER: sub_sub_index=12, end=46, next_colon_index=16, user=17, slash=18, at_sign=17
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.OracleDriver parseUrl
FINER: OracleDriver.parseUrl(url):return
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.OracleDriver connect
FINER: user=theUser, password=******, database=//theServer:1521/theService, protocol=thin, prefetch=null, batch=null, accumulate batch result =true, remarks=null, synonyms=null
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.PhysicalConnection <init>
FINE: PhysicalConnection.PhysicalConnection(ur="jdbc:oracle:thin:@//theServer:1521/theService", us="theUser", p="******", db="//theServer:1521/theService", info)
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.PhysicalConnection <init>
FINEST: PhysicalConnection.PhysicalConnection() : connectionProperties={user=theUser, password=******, protocol=thin}
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.PhysicalConnection initialize
FINE: PhysicalConnection.initialize(ur="jdbc:oracle:thin:@//theServer:1521/theService", us="theUser", access)
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.PhysicalConnection initialize
FINE: PhysicalConnection.initialize(ur, us):return
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.PhysicalConnection needLine
FINE: PhysicalConnection.needLine()--no return
java.lang.ArrayIndexOutOfBoundsException: 31
        at oracle.net.nl.NVTokens.parseTokens(Unknown Source)
        at oracle.net.nl.NVFactory.createNVPair(Unknown Source)
        at oracle.net.nl.NLParamParser.addNLPListElement(Unknown Source)
        at oracle.net.nl.NLParamParser.initializeNlpa(Unknown Source)
        at oracle.net.nl.NLParamParser.<init>(Unknown Source)
        at oracle.net.resolver.TNSNamesNamingAdapter.loadFile(Unknown Source)
        at oracle.net.resolver.TNSNamesNamingAdapter.checkAndReload(Unknown Source)
        at oracle.net.resolver.TNSNamesNamingAdapter.resolve(Unknown Source)
        at oracle.net.resolver.NameResolver.resolveName(Unknown Source)
        at oracle.net.resolver.AddrResolution.resolveAndExecute(Unknown Source)
        at oracle.net.ns.NSProtocol.establishConnection(Unknown Source)
        at oracle.net.ns.NSProtocol.connect(Unknown Source)
        at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1037)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:282)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:468)
        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:839)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)

如果我使用 OracleDataSource 而不是通用的 DriverManager.getConnection(),也会引发上述异常。

关于为什么不同环境中行为不同的任何想法?

I have some Java code that connects to an Oracle database using DriverManager.getConnection(). It works just fine on my Windows XP machine. However, when running the same code on a Solaris machine, I get the following exception. Both machines can reach the database machine on the network. I have included the Oracle trace logs.

Mar 23, 2010 12:12:33 PM org.apache.commons.configuration.ConfigurationUtils locate
FINE: ConfigurationUtils.locate(): base is /users/theUser/ADCompare, name is props.txt
Mar 23, 2010 12:12:33 PM org.apache.commons.configuration.ConfigurationUtils locate
FINE: Loading configuration from the path /users/theUser/ADCompare/props.txt
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.OracleDriver connect
FINE: OracleDriver.connect(url=jdbc:oracle:thin:@//theServer:1521/theService, info)
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.OracleDriver connect
FINER: OracleDriver.connect() walletLocation:(null)
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.OracleDriver parseUrl
FINER: OracleDriver.parseUrl(url=jdbc:oracle:thin:@//theServer:1521/theService)
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.OracleDriver parseUrl
FINER: sub_sub_index=12, end=46, next_colon_index=16, user=17, slash=18, at_sign=17
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.OracleDriver parseUrl
FINER: OracleDriver.parseUrl(url):return
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.OracleDriver connect
FINER: user=theUser, password=******, database=//theServer:1521/theService, protocol=thin, prefetch=null, batch=null, accumulate batch result =true, remarks=null, synonyms=null
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.PhysicalConnection <init>
FINE: PhysicalConnection.PhysicalConnection(ur="jdbc:oracle:thin:@//theServer:1521/theService", us="theUser", p="******", db="//theServer:1521/theService", info)
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.PhysicalConnection <init>
FINEST: PhysicalConnection.PhysicalConnection() : connectionProperties={user=theUser, password=******, protocol=thin}
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.PhysicalConnection initialize
FINE: PhysicalConnection.initialize(ur="jdbc:oracle:thin:@//theServer:1521/theService", us="theUser", access)
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.PhysicalConnection initialize
FINE: PhysicalConnection.initialize(ur, us):return
Mar 23, 2010 12:12:33 PM oracle.jdbc.driver.PhysicalConnection needLine
FINE: PhysicalConnection.needLine()--no return
java.lang.ArrayIndexOutOfBoundsException: 31
        at oracle.net.nl.NVTokens.parseTokens(Unknown Source)
        at oracle.net.nl.NVFactory.createNVPair(Unknown Source)
        at oracle.net.nl.NLParamParser.addNLPListElement(Unknown Source)
        at oracle.net.nl.NLParamParser.initializeNlpa(Unknown Source)
        at oracle.net.nl.NLParamParser.<init>(Unknown Source)
        at oracle.net.resolver.TNSNamesNamingAdapter.loadFile(Unknown Source)
        at oracle.net.resolver.TNSNamesNamingAdapter.checkAndReload(Unknown Source)
        at oracle.net.resolver.TNSNamesNamingAdapter.resolve(Unknown Source)
        at oracle.net.resolver.NameResolver.resolveName(Unknown Source)
        at oracle.net.resolver.AddrResolution.resolveAndExecute(Unknown Source)
        at oracle.net.ns.NSProtocol.establishConnection(Unknown Source)
        at oracle.net.ns.NSProtocol.connect(Unknown Source)
        at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1037)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:282)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:468)
        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:839)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)

The above exception is also thrown if I use OracleDataSource instead of the generic DriverManager.getConnection().

Any ideas on why the behavior is different in the different environments?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黑凤梨 2024-09-02 19:18:23

看起来 TNSNAMES.ORA 中存在一个错误,从

java.lang.ArrayIndexOutOfBoundsException: 31
        at oracle.net.nl.NVTokens.parseTokens(Unknown Source)
        ...
        at oracle.net.resolver.TNSNamesNamingAdapter.loadFile(Unknown Source)

I'm not up on the oracle configuration from Solaris 的行来看,但假设它与 win 版本类似,也许您对该文件的格式有问题。您可以通过该盒子的 sqlplus 控制台进行连接吗?

It looks like there's an error in TNSNAMES.ORA from the lines

java.lang.ArrayIndexOutOfBoundsException: 31
        at oracle.net.nl.NVTokens.parseTokens(Unknown Source)
        ...
        at oracle.net.resolver.TNSNamesNamingAdapter.loadFile(Unknown Source)

I'm not up on the oracle configuration from solaris, but assuming it's similar to the win version, maybe you have an issue with the formatting of this file. Can you connect through a sqlplus console from that box?

仙气飘飘 2024-09-02 19:18:23

我忘记提及的一件事是我的应用程序是为 Java6 构建的。 Oracle数据库是10g,但无论出于什么原因,升级到11g版本的驱动程序(即ojdbc6_g.jar)解决了问题。

One thing I forgot to mention is that my application is built for Java6. The Oracle database is 10g, but for whatever reason, upgrading to the 11g version of the driver (i.e. ojdbc6_g.jar) fixed the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文