List<User> getUser(){};报错
publicstaticList<User>getUsers(){List<User>users=newArrayList<User>();Connectionconn=...
public static List<User> getUsers() {
List<User> users = new ArrayList<User>();
Connection conn = DataBase.GetConn();
String sql = "select * from user";
Statement stmt = DataBase.getStatement(conn);
ResultSet rs = DataBase.getResultSet(stmt, sql);
try {
while (rs.next()) {
User u = new User();
u.SetId(rs.getInt("id"));
u.SetUserName(rs.getString("username"));
u.SetPassword(rs.getString("password"));
u.SetPhone(rs.getString("phone"));
u.SetAddr(rs.getString("addr"));
u.SetRegDate(rs.getDate("rdate"));
users.add(u);
} 展开
List<User> users = new ArrayList<User>();
Connection conn = DataBase.GetConn();
String sql = "select * from user";
Statement stmt = DataBase.getStatement(conn);
ResultSet rs = DataBase.getResultSet(stmt, sql);
try {
while (rs.next()) {
User u = new User();
u.SetId(rs.getInt("id"));
u.SetUserName(rs.getString("username"));
u.SetPassword(rs.getString("password"));
u.SetPhone(rs.getString("phone"));
u.SetAddr(rs.getString("addr"));
u.SetRegDate(rs.getDate("rdate"));
users.add(u);
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询