|
@@ -9,6 +9,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+
|
|
|
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
|
|
import com.mchange.v2.c3p0.DataSources;
|
|
|
|
|
@@ -199,4 +201,21 @@ public class DBUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 转换为数据库模糊查询匹配模式
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @param column
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String toSqlSearchPattern(String column) {
|
|
|
+ if (StringUtils.isBlank(column)) {
|
|
|
+ return "%";
|
|
|
+ } else {
|
|
|
+ column = column.trim().replaceAll("\\s", "%");
|
|
|
+ column = "%" + column + "%";
|
|
|
+ return column;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|