1. 2018-08-20 从异常信息中截取失败的原因
- 需求:从如下异常信息中取出导致失败的数据列值,需要匹配的字符(示例)为
(batch_no, order_id, payment_model)=(20180819043, APK9275585443, 交易退款)
### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "pk_c_alipay_original_data"
详细:Key (batch_no, order_id, payment_model)=(20180819043, APK9275585443, 交易退款) already exists.
; SQL []; ERROR: duplicate key value violates unique constraint "pk_c_alipay_original_data"
详细:Key (batch_no, order_id, payment_model)=(20180819043, APK9275585443, 交易退款) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "pk_c_alipay_original_data"
详细:Key (batch_no, order_id, payment_model)=(20180819043, APK9275585443, 交易退款) already exists.
String regexp = "\\(batch_no, order_id, payment_model\\)=\\(.*\\)";
Pattern pattern = Pattern.compile(regexp);
Matcher matcher = pattern.matcher(msg);
if (matcher.find()) {
System.out.println(matcher.group(0));
}