Dodanie selectAlbums()

This commit is contained in:
Agnieszka Janicka 2016-06-05 00:50:12 +02:00
parent 4280ed4032
commit 8a208b6fe0

View File

@ -84,6 +84,26 @@ public class Database {
return books;
}
public List<Album> selectAlbums() {
List<Album> albums = new LinkedList<Album>();
try {
ResultSet result = stat.executeQuery("SELECT * FROM albums");
int id, year;
String name, musican, category;
while(result.next()) {
id = result.getInt("id");
year = result.getInt("year");
name = result.getString("name");
musican = result.getString("musican");
category = result.getString("category");
albums.add(new Album(id, name, musican, year, category));
}
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Błąd przy odczycie z bazy.", "Error:", JOptionPane.INFORMATION_MESSAGE);
}
return albums;
}
public void closeConnection() {