|
@@ -762,16 +762,7 @@ public class PrintServiceImpl implements PrintService {
|
|
|
* @throws SQLException
|
|
* @throws SQLException
|
|
|
*/
|
|
*/
|
|
|
private int getCount(Connection connection, String sql) throws SQLException {
|
|
private int getCount(Connection connection, String sql) throws SQLException {
|
|
|
- Pattern pattern = Pattern.compile("^\\s*select\\s+[\\s\\S]*?\\s+from");
|
|
|
|
|
- Matcher matcher = pattern.matcher(sql.toLowerCase());
|
|
|
|
|
- if (matcher.find()) {
|
|
|
|
|
- String group = matcher.group();
|
|
|
|
|
- sql = "select count(1) from " + sql.substring(group.length());
|
|
|
|
|
- group.length();
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new ReportException("SQL语法错误:" + sql);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ sql = "select count(1) from (" + sql + ")";
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
|
PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
|
|
ResultSet resultSet = preparedStatement.executeQuery();
|
|
ResultSet resultSet = preparedStatement.executeQuery();
|
|
|
resultSet.next();
|
|
resultSet.next();
|