当前位置: 首页>>代码示例>>Java>>正文


Java MysqlDataTruncation类代码示例

本文整理汇总了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());
    }

}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:11,代码来源:ConnectionRegressionTest.java

示例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;
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:15,代码来源:MessageParserImpl.java

示例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;
}
 
开发者ID:ivan-zapreev,项目名称:x-cure-chat,代码行数:13,代码来源:UpdateForumMessageExecutor.java

示例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());
	}

}
 
开发者ID:hinsenchan,项目名称:fil_project_mgmt_app_v2,代码行数:14,代码来源:ConnectionRegressionTest.java

示例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
}
 
开发者ID:davidcarboni,项目名称:cheep-orm,代码行数:22,代码来源:BeanColumnDefinitionTest.java

示例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 );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:19,代码来源:DatabaseLogExceptionFactoryTest.java

示例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);
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:52,代码来源:ErrorUtil.java


注:本文中的com.mysql.jdbc.MysqlDataTruncation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。