Dodanie selectAlbums()
This commit is contained in:
parent
4280ed4032
commit
8a208b6fe0
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user