public Account getAccountById(Integer accountId) {
Account a=null;
try(Connection conn=JdbcUtil.getConnection();
PreparedStatement ps=(PreparedStatement) conn.prepareStatement(sql_selectOne)){
ps.setInt(1, accountId);
ResultSet rs=ps.executeQuery();
if(rs.next()) {
a=new Account();
a.setAccountid(rs.getInt(1));
a.setName(rs.getString(2));
a.setremain(rs.getInt(3));
}
}catch(Exception e) {
e.printStackTrace();
}return a;
}
public List<Account> getAll() {
List<Account> list=new ArrayList<Account>();
try(Connection conn=JdbcUtil.getConnection();
PreparedStatement ps=(PreparedStatement) conn.prepareStatement(sql_select);
ResultSet rs=ps.executeQuery();){
while(rs.next()) {
Account a=new Account();
a.setAccountid(rs.getInt(1));
a.setName(rs.getString(2));
a.setremain(rs.getInt(3));
list.add(a);
}
}catch(Exception e) {
e.printStackTrace();
}
return list;
}