@Override public ImagesPage findByIdWithoutData(int idImg) { ImagesPage image = null; String sql = "SELECT * FROM imagespages WHERE id=" + idImg; try { conn = myDataSource.getConnection(); Statement stat = conn.createStatement(); ResultSet rs = stat.executeQuery(sql); if (rs.next()) { image = new ImagesPage(); image.setId(rs.getInt(1)); image.setDirectory(rs.getString(5)); image.setFilename(rs.getString(4)); image.setIdPageText(rs.getInt(3)); } } catch (SQLException ex) { LOG.log(Level.SEVERE, null, ex); } finally { try { conn.close(); } catch (SQLException ex) { LOG.log(Level.SEVERE, null, ex); } } return image; }
@Override public List<ImagesPage> findAllWithoutData() { List<ImagesPage> imagesList = new ArrayList<>(); ImagesPage image = null; String sql = "SELECT * FROM imagespages"; Statement stat = null; ResultSet rs = null; try { conn = myDataSource.getConnection(); stat = conn.createStatement(); rs = stat.executeQuery(sql); while (rs.next()) { image = new ImagesPage(); image.setId(rs.getInt(1)); image.setDirectory(rs.getString(5)); image.setFilename(rs.getString(4)); image.setIdPageText(rs.getInt(3)); imagesList.add(image); } } catch (SQLException ex) { LOG.log(Level.SEVERE, null, ex); } finally { try { stat.close(); rs.close(); conn.close(); } catch (SQLException ex) { LOG.log(Level.SEVERE, null, ex); } } return imagesList; }