1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| @ManagedBean (name="DataBaseO")
@ApplicationScoped
public class DataBaseO {
private static Statement statement;
private ResultSet result;
@ManagedProperty(value="#{ManagedBeanO.connectedUser}")
private Connection connectedUser; // +setter
public ResultSet getAll() throws SQLException, IOException, InstantiationException, IllegalAccessException, ClassNotFoundException
{ try {
statement = connectedUser.createStatement();
Statement stmt = connectedUser.createStatement();
ResultSet result = stmt.executeQuery("SELECT * FROM all_tables");
CachedRowSet crs = new com.sun.rowset.CachedRowSetImpl();
crs.populate(result);
return crs;
}
finally {
connectedUser.close();
}
}
} |
Partager