本文整理汇总了Java中java.sql.DatabaseMetaData.supportsTransactionIsolationLevel方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseMetaData.supportsTransactionIsolationLevel方法的具体用法?Java DatabaseMetaData.supportsTransactionIsolationLevel怎么用?Java DatabaseMetaData.supportsTransactionIsolationLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.DatabaseMetaData
的用法示例。
在下文中一共展示了DatabaseMetaData.supportsTransactionIsolationLevel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIsolationLevel
import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
/**
* Tests isolation level functionality
*
* @throws Exception
* if an error occurs
*/
public void testIsolationLevel() throws Exception {
if (versionMeetsMinimum(4, 0)) {
String[] isoLevelNames = new String[] { "Connection.TRANSACTION_NONE", "Connection.TRANSACTION_READ_COMMITTED",
"Connection.TRANSACTION_READ_UNCOMMITTED", "Connection.TRANSACTION_REPEATABLE_READ", "Connection.TRANSACTION_SERIALIZABLE" };
int[] isolationLevels = new int[] { Connection.TRANSACTION_NONE, Connection.TRANSACTION_READ_COMMITTED, Connection.TRANSACTION_READ_UNCOMMITTED,
Connection.TRANSACTION_REPEATABLE_READ, Connection.TRANSACTION_SERIALIZABLE };
DatabaseMetaData dbmd = this.conn.getMetaData();
for (int i = 0; i < isolationLevels.length; i++) {
if (dbmd.supportsTransactionIsolationLevel(isolationLevels[i])) {
this.conn.setTransactionIsolation(isolationLevels[i]);
assertTrue(
"Transaction isolation level that was set (" + isoLevelNames[i]
+ ") was not returned, nor was a more restrictive isolation level used by the server",
this.conn.getTransactionIsolation() == isolationLevels[i] || this.conn.getTransactionIsolation() > isolationLevels[i]);
}
}
}
}