最近学习Spring+ibatis的时候 碰到一个问题:部分代码如下
msgTempSend.setSendtype("2222222222222");
public Object insertStudent(Student student) {
return sqlMapClientTemplate.insert("Student.insertStudent", student);
}
如上 数据库中Sendtype 字段 是number(2),所以在插入时候的应该会插入异常。但是我的代码在执行的时候日志到
2010-04-16 14:34:41,359 INFO [org.springframework.jdbc.support.SQLErrorCodesFactory] - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
2010-04-16 14:34:41,359 DEBUG [org.springframework.jdbc.support.SQLErrorCodesFactory] - Looking up default SQLErrorCodes for DataSource [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy@ed7d11]
2010-04-16 14:34:41,359 DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] - Fetching JDBC Connection from DataSource
2010-04-16 14:34:41,359 DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] - Fetching JDBC Connection from DataSource
就停下了。。没有异常信息。
另外如果插入的值正常的话。是可以成功插入的。。
第二个问题:我看API insert方法应该会throws 一个异常 ,但是为什么在编码时。没有try catch()不报错???如果程序异常的。应该怎样捕获这个异常呢???高手??