Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static String QUERY_SELECT_ALL = "select * from Osoba";
- public List<OsobaDTO> getAll() {
- List<OsobaDTO> data = new ArrayList<OsobaDTO>();
- OsobaDTO member;
- Connection con = null;
- PreparedStatement ps = null;
- ResultSet rs = null;
- try {
- con = getOracleConnection();
- ps = con.prepareStatement(QUERY_SELECT_ALL);
- rs = ps.executeQuery();
- while (rs.next()) {
- member = new OsobaDTO();
- member.setId(rs.getInt(1));
- member.setName(rs.getString(2));
- member.setAdresa(rs.getString(3));
- ...
- data.add(member);
- }
- System.out.println("Persons imported successfully.");
- return data;
- }
- catch (SQLException ex) {
- Logger.getLogger(OracleDodavatelDAO.class.getName()).log(Level.SEVERE, null, ex);
- return null;
- }
- finally {
- if (con != null) {
- try {
- con.close();
- }
- catch (SQLException ex) {
- Logger.getLogger(OracleDodavatelDAO.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment