@Override
	public int getTotalRowCount(Connection con, String mainSubSql, Values values) {
		String viewName = "SYS_"
				+ UUID.randomUUID().toString().replaceAll("-", "");
		try {
			{
				String createViewSql = "create view " + viewName + " as "
						+ mainSubSql + "";
				DbUtil.printSql(createViewSql, values);
				PreparedStatement ps = null;
				try {
					ps = con.prepareStatement(createViewSql);
					DbUtil.setColumnValue(ps, 1, values);
					ps.executeUpdate();
				} catch (SQLException e) {
					throw new DbKingException(e);
				} finally {
					DbUtil.closeStatement(ps);
				}
			}
			{
				String countSql = "select count(*) from " + viewName;
				DbUtil.printSql(countSql, values);
				PreparedStatement ps = null;
				ResultSet rs = null;
				try {
					ps = con.prepareStatement(countSql);
					DbUtil.setColumnValue(ps, 1, values);
					rs = ps.executeQuery();
					if (rs.next()) {
						return rs.getBigDecimal(1).intValue();
					} else {
						throw new DbKingException("no resultset");
					}
				} catch (SQLException e) {
					throw new DbKingException(e);
				} finally {
					DbUtil.closeResultSet(rs);
					DbUtil.closeStatement(ps);
				}
			}
		} finally {
			String dropViewSql = "drop view if exists " + viewName;
			DbUtil.printSql(dropViewSql, new Values());
			Statement statement = null;
			try {
				statement = con.createStatement();
				statement.executeUpdate(dropViewSql);
			} catch (SQLException e) {
				throw new DbKingException(e);
			} finally {
				DbUtil.closeStatement(statement);
			}
		}
	}