sql执行错误,只提取数据表和字段不存在的关键信息
public static void main(String[] args) {
//需要匹配的字符串
String str = "异常信息,org.postgresql.util.PSQLException: ERROR: column a.input_time does not exist Position: 131 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433) at ";
//正则表达式
String patternStr = "\\b(relation|column).*\\b(exist)";
//一个Pattern对象和一个正则表达式相关联
Pattern pattern = Pattern.compile(patternStr);
//一个Matcher对象和一个具体的字符串相关联,表示在指定模式下与这个字符串匹配
Matcher matcher = pattern.matcher(str);
//截取匹配的字符串
while(matcher.find()){
String str1 = matcher.group();
System.out.println("11:"+str1);
}
}