我想捕捉 java.sql.SQLDataException: ORA-01438: 值大於此資料欄所允許的指定精確度
這個Exception
預想是當出現這個EXCEPTION時 print "我想印出這行"
但結果卻是印出*****
以下是簡略過後的程式碼
public String createOrder(String orderno) {
String msg =null;
try {
testDao.createOrder(orderno);
} catch (SQLException se) {
logger.error(se);
System.out.println("我想印出這行");
return "3";
} catch (Exception e) {
logger.error(e);
System.out.println("*****");
return "1";
}
return msg;
}
testDao
public void createOrder(final String orderno)throws Exception{
String sql=" INSERT INTO ORDER ( ORDER_NO ) "
+" VALUES(?) ";
oracleJdbcTemplate.update(sql, new PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws SQLException {
ps.setString(1,orderno);
}
} );
}
請問該如何改?
it is because the Exception throws is NOT SQLDataException.
So you should first make sure what excepttion is it.
change the line from :
} catch (Exception e) {
logger.error(e);
System.out.println("*****");
return "1";
}
to
} catch (Exception e) {
e.printStackTrace() ;
System.out.println("*****"+e.getClass().getName());
return "1";
}
Check what kind of exception is it.
or you can post the error log here for reference.