1、留着自己以後查看的:
DataSource dataSource = null;
Connection connection = null;
ResultSet rs = null;
dataSource = (DataSource) BeanFactoryUtil.getBean("fibre");
connection = dataSource.getConnection();
Statement st = connection.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
try {
//System.out.print(sql);
rs = st.executeQuery(sql);
CachedRowSet rowset = createCachedRowset();
rowset.populate(rs);
rs.close();
return rowset;
} catch (SQLException ex) {
Logger.getLogger(this.getClass().getName()).log(Level.ERROR, null,
ex);
return null;
} finally {
if (st != null) {
st.close();
}
if (connection != null) {
connection.close();
}
}