Jdbc check for capability - savepoint release

孤人 提交于 2020-01-30 05:03:09

问题


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) 

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

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.

Thanks


回答1:


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

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".

In 11g, the documentation seems to claim otherwise:

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

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



来源:https://stackoverflow.com/questions/10667292/jdbc-check-for-capability-savepoint-release

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!