基于SQL的通用select方法
public ArrayList select(String sql) throws Exception{
Session session = HibernateSessionFactory.currentSession();
Connection con = session.connection();
PreparedStatement pstmt = con.preparedStatement(sql);
ResultSet rs = pstmt.executeQuery();
ResultSetMetaData rsmd = rs.getMetaData();
Hashtable ht = null;
ArrayList array = new ArrayList();
while(rs.next()){
ht = new Hashtable();
for(int i=0;i
}
array.add(ht);
}
HibernateSessionFactory.clossSession();
return array;
}
文章来源于领测软件测试网 https://www.ltesting.net/