From d7f68f380a90661cac3048264e8b773f27c7eba1 Mon Sep 17 00:00:00 2001 From: User_cyk <1020691186@qq.com> Date: Sat, 1 Jul 2023 13:07:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/hellogithub/dao/projectDao.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/hellogithub/dao/projectDao.java b/src/com/hellogithub/dao/projectDao.java index cfe2ed3..880decd 100644 --- a/src/com/hellogithub/dao/projectDao.java +++ b/src/com/hellogithub/dao/projectDao.java @@ -56,11 +56,13 @@ public class projectDao { */ public int countAll() { int count; + projectEntity p; try { Connection conn = JdbcUtils.getConnection(); QueryRunner runner = new QueryRunner(); - String sql = "select count(1) from project"; - count = runner.query(conn, sql, new BeanHandler<>(Integer.class)); + String sql = "select count(*) as projectId from project"; + p = runner.query(conn, sql, new BeanHandler<>(projectEntity.class)); + count = p.getProjectId(); conn.close(); } catch (SQLException e) { throw new RuntimeException(e); @@ -118,7 +120,7 @@ public class projectDao { try { Connection conn = JdbcUtils.getConnection(); QueryRunner runner = new QueryRunner(); - String sql = "select * from project where projectId in (select projectId from project_category where categoryId=?) order by lookCount"; + String sql = "select * from project where projectId in (select projectId from project_category where categoryId=?) order by lookCount desc"; projectEntityList = runner.query(conn, sql, new BeanListHandler<>(projectEntity.class),cateid); conn.close(); } catch (SQLException e) {