Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ArrayList<Libro> getAll()
- {
- ArrayList<Libro> libros = new ArrayList<Libro>();
- ConeccionDB con = new ConeccionDB();
- Statement st = null;
- ResultSet rs = null;
- String queryString = "SELECT * FROM libros ORDER BY titulo;";
- try
- {
- st = con.getConnection().createStatement();
- rs = st.executeQuery(queryString);
- while(rs.next())
- {
- Libro libro = new Libro();
- libro.setID(rs.getInt("id_libro"));
- libro.setTitulo(rs.getString("titulo"));
- libro.setAutor(rs.getString("autor"));
- libros.add(libro);
- }
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- finally
- {
- try
- {
- con.getConnection().close();
- rs.close();
- st.close();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- return libros;
- }
Advertisement
Add Comment
Please, Sign In to add comment