You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tank/UserDaodyh.java

30 lines
960 B

package com.dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.entity.Userdyh;
import com.utils.DBUtilhxr;
public class UserDaodyh {
public static List<Userdyh> query() throws Exception{
Connection con = DBUtilhxr.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select id,user,password from user_info");
List<Userdyh> userList = new ArrayList<Userdyh>();
Userdyh user = null;
// 如果对象中有数据,就会循环打印出来
while (rs.next()){
user = new Userdyh(); // 调用模型层
user.setID(rs.getInt("id"));
user.setUserName(rs.getString("user"));
user.setPassword(rs.getString("password"));
userList.add(user);
}
return userList;
}
}