jdbc利用集合传递参数
司毅庵
2023-12-01
public static List<Emp> queryColor() {
// TODO Auto-generated method stub
List<Emp> table =new ArrayList<Emp>();
Connection con=null;
Statement sta=null;
ResultSet re=null;
String sql="select * from emp";
try {
con=JdbcUtil.getConn();
sta=con.createStatement();
re=sta.executeQuery(sql);
while(re.next())
{
Emp emp=new Emp();
emp.setName(re.getString("name"));
emp.setId(re.getInt("id"));
table.add(emp);
System.out.println(emp);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
}
return table;
}