本文整理汇总了Java中com.mysql.jdbc.exceptions.MySQLTransientException类的典型用法代码示例。如果您正苦于以下问题:Java MySQLTransientException类的具体用法?Java MySQLTransientException怎么用?Java MySQLTransientException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MySQLTransientException类属于com.mysql.jdbc.exceptions包,在下文中一共展示了MySQLTransientException类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testBug16634180
import com.mysql.jdbc.exceptions.MySQLTransientException; //导入依赖的package包/类
/**
* Tests fix for Bug#16634180 - LOCK WAIT TIMEOUT EXCEEDED CAUSES SQLEXCEPTION, SHOULD CAUSE SQLTRANSIENTEXCEPTION
*
* @throws Exception
* if the test fails.
*/
public void testBug16634180() throws Exception {
if (Util.isJdbc4()) {
// relevant JDBC4+ test is testsuite.regression.jdbc4.ConnectionRegressionTest.testBug16634180()
return;
}
createTable("testBug16634180", "(pk integer primary key, val integer)", "InnoDB");
this.stmt.executeUpdate("insert into testBug16634180 values(0,0)");
Connection c1 = null;
Connection c2 = null;
try {
c1 = getConnectionWithProps(new Properties());
c1.setAutoCommit(false);
Statement s1 = c1.createStatement();
s1.executeUpdate("update testBug16634180 set val=val+1 where pk=0");
c2 = getConnectionWithProps(new Properties());
c2.setAutoCommit(false);
Statement s2 = c2.createStatement();
try {
s2.executeUpdate("update testBug16634180 set val=val+1 where pk=0");
fail("ER_LOCK_WAIT_TIMEOUT should be thrown.");
} catch (MySQLTransientException ex) {
assertEquals(MysqlErrorNumbers.ER_LOCK_WAIT_TIMEOUT, ex.getErrorCode());
assertEquals(SQLError.SQL_STATE_ROLLBACK_SERIALIZATION_FAILURE, ex.getSQLState());
assertEquals("Lock wait timeout exceeded; try restarting transaction", ex.getMessage());
}
} finally {
if (c1 != null) {
c1.close();
}
if (c2 != null) {
c2.close();
}
}
}
开发者ID:bragex,项目名称:the-vigilantes,代码行数:46,代码来源:ConnectionRegressionTest.java
示例2: getResult
import com.mysql.jdbc.exceptions.MySQLTransientException; //导入依赖的package包/类
/**
* Convert column Type into actual type.
*/
public static Object getResult(ResultSet resultSet, String columnName, int columnType) throws SQLException {
TypeHandler handler = null;
handler = TypeHandlerFactory.getTypeHandler(columnType);
if (handler == null) {
throw new MySQLTransientException();
}
else {
return handler.getResult(resultSet, columnName);
}
}
开发者ID:luoxn28,项目名称:WeMybatis,代码行数:15,代码来源:ColumnTypeHandler.java
注:本文中的com.mysql.jdbc.exceptions.MySQLTransientException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论