Java 學習記錄122 — Query Artists for Song method

package musicDB;
import musicDB.model.Artist;
import musicDB.model.Datasource;
import javax.swing.*;
import java.util.List;
public class Main {
public static void main(String[] args) {
Datasource dataSource = new Datasource();
if (!dataSource.open()) {
System.out.println("Can't open datasource");
return;
}
List<Artist> artists = dataSource.queryArtists(Datasource.SortOrder.ORDER_BY_ASC);
if (artists == null) {
System.out.println("No artists!");
return;
}
for (Artist artist : artists) {
// System.out.println(artist);
}
List<String> albumsForArtist = dataSource.queryAlbumsForArtist("Pink Floyd", Datasource.SortOrder.ORDER_BY_DESC); for (String album : albumsForArtist) {
System.out.println(album);
}
dataSource.close();
}
}
List<String> albumsForArtist = dataSource.queryAlbumsForArtist("Carole King", Datasource.SortOrder.ORDER_BY_ASC);
SELECT artists.name, albums.name, songs.track FROM songs
INNER JOIN albums ON songs.album = albums._id
INNER JOIN artists ON albums.artist = artists._id
WHERE title = "Go Your Own Way"
ORDER BY artists.name, albums.name
COLLATE NOCASE ASC

上面代碼全都紀錄在我的 Github

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
張小雄

張小雄

記錄成為軟體工程師的過程