JDBC检查功能-保存点发布 [英] Jdbc check for capability - savepoint release

查看:70
本文介绍了JDBC检查功能-保存点发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有适用于所有数据库的通用jdbc代码. 我有一些与事务和保存点一起使用的API.

I have generic jdbc code that works with all kinds of databases. I have some apis that work with transactions and savepoints.

问题是某些数据库要求您手动释放保存点

The problem is that some databases require you to release the savepoint manually

 conn.releaseSavepoint(savepoint1) 

,有些人在进行手动发布时就大肆宣传(最著名的是Oracle).

and some just throw an exeption when you do a manual release (most notably Oracle).

如何在运行时检查数据库是否具有自动保存点释放功能,或者是否需要执行该操作 手动.还有,我有一些不错的API.我不想抓住例外,这很丑陋 并且在这种情况下容易出错.引发的异常是 java.sql.SqlException ,而不是"FeatureUnsupportedException"之类的东西.因此,如果存在真正的错误并且我愚蠢地抓住了它,那么我可能会在整个事务中完全失败.

How can I check at run-time if the db has automatic savepoint release or if I need to do it manually. And pls, I have some nice apis. I don't want to catch the exception, it's ugly and error-prone in this case. The exception thrown is java.sql.SqlException, not something like "FeatureUnsupportedException". So if there is a real error and I foolishly catch it then I could fail at the whole transaction thing altogether.

谢谢

推荐答案

In Oracle's 10g documentation, I could spot the fact that this particular JDBC / ojdbc method is not supported:

注意: 从Oracle Database 10g开始,不支持releaseSavepoint和oracleReleaseSavepoint.如果调用这两个方法中的任何一个,则会引发SQLException并显示消息不支持的功能".

Note: As of Oracle Database 10g, releaseSavepoint and oracleReleaseSavepoint are not supported. If you call either of the methods, then SQLException is thrown with the message "Unsupported feature".

在11g中,该文档似乎已声明否则:

您可以使用Connection.releaseSavepoint(Savepoint svpt)方法删除一个保存点.

You remove a savepoint using the Connection.releaseSavepoint(Savepoint svpt) method.

但是我也可以轻松地用11g重现您的问题.

But I can easily reproduce your issue also in 11g.

这篇关于JDBC检查功能-保存点发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆