Adds the ability to add internet songs to the library.

This commit is contained in:
Markil3
2021-08-15 18:18:02 -06:00
parent 76594b279c
commit b546c81fa1
7 changed files with 714 additions and 35 deletions

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 2021 William Hubbard. All Rights Reserved.
*/
package edu.regis.universeplayer.data;
import edu.regis.universeplayer.player.Interface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLWarning;
/**
* Manages the application song database
*/
public class DatabaseManager
{
private static final Logger logger = LoggerFactory.getLogger(DatabaseManager.class);
private static Connection db;
public static synchronized Connection getDb()
{
SQLWarning warning;
try
{
if (db == null || db.isClosed())
{
Class.forName("org.sqlite.JDBC");
db = DriverManager.getConnection("jdbc:sqlite:" + new File(Interface.getDataDir().getAbsolutePath(), "universalmusic.db").getAbsolutePath());
}
warning = db.getWarnings();
while (warning != null)
{
logger.warn("SQL Warning: ", warning);
warning = warning.getNextWarning();
}
db.clearWarnings();
}
catch (SQLException | ClassNotFoundException e)
{
logger.error("Could not store caching DIR.");
}
return db;
}
}