Java JDBC Oracle 9i升级到10g问题

发布于 2024-09-06 21:55:41 字数 351 浏览 2 评论 0原文

我们刚刚从 Oracle 9i 升级到 10g,我的数据库查询适用于 9i 客户端,但不适用于 10g。查询中没有任何变化。我收到以下错误:

java.sql.SQLException: ORA-01036: illegal variable name/number

不太确定发生了什么。为什么不再运行了。它只是一个连接大约 3 或 4 个表的 select 语句。我确保使用 setInt 传递变量(这是我正在使用的数字)。在比较要连接的表时,我发现唯一不同的是,在一个表上,我要连接的列设置为一个表上的数字,另一个表上的数字(12)。这有什么区别吗?该查询仍在 TOAD 和 SQL Navigator 中运行...

We have just upgrade from oracle 9i to 10g and a database query I have works with the 9i client but not the 10g. Nothing in the query has changed. I get the following error:

java.sql.SQLException: ORA-01036: illegal variable name/number

Not really sure what is going on. Why wouldn't it run anymore. It's just a select statement which joins about 3 or 4 tables. I am making sure that I am passing in the variable using setInt (it's a number that I'm using). While diff'ing the tables being joined the only thing I find different is that on one table a column I'm joining is set to be a Number on one table and Number(12) on the other. Does this make a difference? The query still runs in TOAD and SQL Navigator...

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

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

发布评论

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

评论(2

掩于岁月 2024-09-13 21:55:41

我的脑海中浮现出两个想法:

  1. 确保您使用的是正确版本的 jdbc 驱动程序。既然您已经说过查询可以在 TOAD 等中工作,那么这很可能是您的问题。
  2. 确保您在查询中没有使用任何 ORACLE 关键字作为列别名等。

另外,根据经验,如果您的数据库很大/很忙,那么在 10g 环境稳定之前您还有很长的路要走。我的建议:

  1. 尽可能多地了解统计数据
  2. 阅读生存指南(网上有很多)
  3. 留意重新计算状态的内置作业。上线 12 天后,我们受到了重创,因为统计数据的更改破坏了关键查询性能。我们的测试不允许进行 12 天的稳定性测试。
  4. 如果您还没有意识到绑定变量窥视,请注意

2 thoughts spring to mind:

  1. make sure you're using the correct version of the jdbc driver. Since you've said the query works in TOAD etc, this is very likely to be your problem.
  2. make sure you're not using any ORACLE key-words in your query as column-aliases etc

Also, from experience if your database is big/busy you've got a fair way to go before your 10g environment is stable. My recommendations:

  1. learn as much as you can about stats
  2. Read the survival guides (there's lots on the net)
  3. watch out for built-in jobs that re-compute status. We got hammered 12 days after go-live because stats changes broke key query performance. Our testing hadn't allowed a 12 day stability test.
  4. be aware of bind-variable-peeking if you aren't already
〆凄凉。 2024-09-13 21:55:41

问题出在准备好的语句上的以下方法调用:

ps.setEscapeProcessing(false);

删除了它,现在它工作正常。不认为这与 oracle 10g 驱动程序兼容。感谢大家的帮助。

The problem was with the following method call on the prepared statement:

ps.setEscapeProcessing(false);

Removed that and now it works fine. Don't think that was compatable with oracle 10g driver. Thanks everyone for the help.

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