String sql = "insert into library.file_headertag_import (path, filename, extension,"
+ "bitrate, vbr, duration, artist_name, album_artist_name, composer_name,"
+ "album_name, track_name, track_nr, track_nrs, disc_nr, disc_nrs, year,"
+ "tag_name, lyrics, coverart, artistsort_name, albumartistsort_name) values"
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
BatchSqlUpdate batch = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batch.declareParameter(new SqlParameter("path", Types.VARCHAR));
batch.declareParameter(new SqlParameter("filename", Types.VARCHAR));
batch.declareParameter(new SqlParameter("extension", Types.VARCHAR));
batch.declareParameter(new SqlParameter("bitrate", Types.SMALLINT));
batch.declareParameter(new SqlParameter("vbr", Types.BOOLEAN));
batch.declareParameter(new SqlParameter("duration", Types.SMALLINT));
batch.declareParameter(new SqlParameter("artist_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("album_artist_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("composer_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("album_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("track_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("track_nr", Types.SMALLINT));
batch.declareParameter(new SqlParameter("track_nrs", Types.SMALLINT));
batch.declareParameter(new SqlParameter("disc_nr", Types.SMALLINT));
batch.declareParameter(new SqlParameter("disc_nrs", Types.SMALLINT));
batch.declareParameter(new SqlParameter("year", Types.SMALLINT));
batch.declareParameter(new SqlParameter("tag_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("lyrics", Types.VARCHAR));
batch.declareParameter(new SqlParameter("coverart", Types.BOOLEAN));
batch.declareParameter(new SqlParameter("artistsort_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("albumartistsort_name", Types.VARCHAR));
for (File file : files) {
MetaData md = file.getMetadata();
if (md != null) {
batch.update(new Object[]{file.getDirectory(), file.getFilename(),
md.getMediaType().getFilesuffix(), md.getBitrate(), md.isVbr(),
md.getDuration(), md.getArtist(), md.getAlbumArtist(),
md.getComposer(), md.getAlbum(), md.getTitle(), md.getTrackNr(),
md.getTrackNrs(), md.getDiscNr(), md.getDiscNrs(), md.getYear(),
md.getGenre(), md.getLyrics(), md.isCoverArtEmbedded(),
md.getArtistSort(), md.getAlbumArtistSort()});
}
}
batch.flush();
}