第一:聚合函数count后面你没加括号第二:createStatement().executeQuery(sql);这种写法好像不安全,要用prepareStatement(sql)sql = "select count(*) from user where name like ?";PreparedStatement ps =connection.prepareStatement(sql);ResultSet rs =ps.setString(1, "%"+name+"%");while(rs.next()){rs.getInt(1);}