每日随笔

重写查找函数,掌握的不熟练,很多语句不知道干什么用的,只知道需要用

public List<studentid> select() {
String sql = "select * from studentid ";
Connection connection = DBUtil_Studentid.getConnection();
PreparedStatement st = null;
List<studentid> list = new ArrayList<>();
ResultSet rs = null;
studentid stuid = null;
try {
st = connection.prepareStatement(sql);
st.executeQuery(sql);
rs = st.executeQuery(sql);
while (rs.next()) {
int id = rs.getInt("id");
String password = rs.getString("password");
stuid = new studentid(id, password);
list.add(stuid);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DBUtil_Studentid.close(rs);
DBUtil_Studentid.close(st);
DBUtil_Studentid.close(connection);
}
return list;
}

原文地址:https://www.cnblogs.com/buxiang-Christina/p/14157874.html