本文整理汇总了Java中com.mysql.jdbc.MysqlDataTruncation类的典型用法代码示例。如果您正苦于以下问题:Java MysqlDataTruncation类的具体用法?Java MysqlDataTruncation怎么用?Java MysqlDataTruncation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MysqlDataTruncation类属于com.mysql.jdbc包,在下文中一共展示了MysqlDataTruncation类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBug44324
import com.mysql.jdbc.MysqlDataTruncation; //导入依赖的package包/类
public void testBug44324() throws Exception {
createTable("bug44324", "(Id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, SomeVChar VARCHAR(10)) ENGINE=MyISAM;");
try {
this.stmt.executeUpdate("INSERT INTO bug44324 values (null, 'Some text much longer than 10 characters')");
} catch (MysqlDataTruncation sqlEx) {
assertTrue(0 != sqlEx.getErrorCode());
}
}
示例2: parse
import com.mysql.jdbc.MysqlDataTruncation; //导入依赖的package包/类
public static String parse(MysqlDataTruncation exception) {//TODO 这里改成SQLException
String msg;
try {
msg = INSTANCE.parse(exception.getMessage());
if (msg == null) {
msg = exception.getMessage();
}
}
catch (Exception e) {
e.printStackTrace();
msg = e.getMessage();
}
return msg;
}
示例3: executeQuery
import com.mysql.jdbc.MysqlDataTruncation; //导入依赖的package包/类
public ResultSet executeQuery( PreparedStatement pstmt, Void result ) throws SQLException, SiteException {
try {
if( pstmt.executeUpdate() == 0 ) {
logger.error("Could not update the forum message " + message.messageID + " by user " + message.senderID );
throw new MessageException( MessageException.THE_MESSAGE_YOU_UPDATE_DOES_NOT_EXIST );
}
} catch( MysqlDataTruncation e ) {
logger.error( "An unhandled exception when sending a forum message by " + message.senderID, e);
throw new MessageException( MessageException.THE_RESULTING_MESSAGE_IS_TOO_LONG );
}
return null;
}
示例4: testBug44324
import com.mysql.jdbc.MysqlDataTruncation; //导入依赖的package包/类
public void testBug44324() throws Exception {
createTable(
"bug44324",
"(Id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, SomeVChar VARCHAR(10)) ENGINE=MyISAM;");
try {
this.stmt
.executeUpdate("INSERT INTO bug44324 values (null, 'Some text much longer than 10 characters')");
} catch (MysqlDataTruncation sqlEx) {
assertTrue(0 != sqlEx.getErrorCode());
}
}
示例5: testCreateTooLong
import com.mysql.jdbc.MysqlDataTruncation; //导入依赖的package包/类
/**
* Test method for {@link net.jirasystems.cheeporm.Orm#create(java.lang.Object)}.
*
* @throws SQLException .
* @throws IllegalAccessException .
* @throws InstantiationException .
*/
@Test(expected = MysqlDataTruncation.class)
public void testCreateTooLong() throws SQLException, InstantiationException, IllegalAccessException {
// Given
bean = newBean();
String stringValue = "value too long";
bean.setName(stringValue);
// When
orm.create(bean);
// Then
// Expected exception: MysqlDataTruncation
}
示例6: testExceptionStrategyWithMysqlDataTruncationException
import com.mysql.jdbc.MysqlDataTruncation; //导入依赖的package包/类
/**
* PDI-5153
* Test that in case of MysqlDataTruncation exception there will be no stack trace in log
*/
@Test public void testExceptionStrategyWithMysqlDataTruncationException() {
DatabaseMeta databaseMeta = mock( DatabaseMeta.class );
DatabaseInterface databaseInterface = new MySQLDatabaseMeta();
MysqlDataTruncation e = new MysqlDataTruncation();
when( logTable.getDatabaseMeta() ).thenReturn( databaseMeta );
when( databaseMeta.getDatabaseInterface() ).thenReturn( databaseInterface );
LogExceptionBehaviourInterface
exceptionStrategy =
DatabaseLogExceptionFactory.getExceptionStrategy( logTable, new KettleDatabaseException( e ) );
String strategyName = exceptionStrategy.getClass().getName();
assertEquals( SUPPRESSABLE_WITH_SHORT_MESSAGE, strategyName );
}
示例7: parseMessage
import com.mysql.jdbc.MysqlDataTruncation; //导入依赖的package包/类
/**
* 获取异常信息.
*
* @param e
* @return
*/
public static String parseMessage(Throwable e) {
if (e == null) {
throw new IllegalArgumentException("exception不能为空?");
}
String className = e.getClass().getName();
String message = MESSAGE_MAP.get(className);
if (message != null) {
return message;
}
if (e instanceof GenericSignatureFormatError) {
printStartupTime();
return "更新程序后,还没有重启服务.";
}
if (e instanceof NoSuchMethodError) {
printStartupTime();
return "NoSuchMethodError:方法找不到.";
}
if (e instanceof SQLException) {
return "操作数据库出错,请稍后重试.";
}
if (e instanceof DataIntegrityViolationException) {
Exception exception = (Exception) e.getCause();
if (exception instanceof MysqlDataTruncation) {
return MessageParserImpl.parse((MysqlDataTruncation) exception);
}
else {
return "操作数据库出错,请稍后重试.";
}
// try {
// return parseDataIntegrityViolationException((DataIntegrityViolationException) e);
// }
// catch (Exception e1) {
// e1.printStackTrace();
// return "字段太长,请稍后重试.";
// }
}
message = e.getMessage();
if (message == null) {
return null;
}
return fillterDebugInfo(message);
}