started working on new database system using sqlite

This commit is contained in:
potzplitz 2024-03-24 17:46:29 +01:00
parent bcf0e75db1
commit 005758c1e5
8 changed files with 81 additions and 19 deletions

11
pom.xml
View file

@ -37,11 +37,22 @@
<artifactId>jdash-client</artifactId>
<version>4.0.5</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.45.2.0</version>
</dependency>
<dependency>
<groupId>javazoom</groupId>
<artifactId>jlayer</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.10</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>

View file

@ -1,9 +0,0 @@
package data;
public class FetchGDData {
public void getSongData() {
}
}

View file

@ -0,0 +1,15 @@
package database;
public class DatabaseManager {
public void manage() {
Sqlite sql = new Sqlite("test");
if(sql.exists()) {
System.out.println(true);
} else {
System.out.println(false);
sql.createNewDatabase();
}
}
}

38
src/database/Sqlite.java Normal file
View file

@ -0,0 +1,38 @@
package database;
import java.io.File;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.sql.DriverManager;
public class Sqlite {
private static String url = "jdbc:sqlite:C:\\ExtremeDemonList\\database\\sqlite\\";
private static String filename;
public Sqlite(String dbname) { // setzt variablen
url += dbname + ".db";
filename = dbname + "";
}
public boolean exists() { // überprüft, ob datenbank existiert
File file = new File("C:\\ExtremeDemonList\\database\\sqlite\\" + filename + ".db");
if(file.exists()) {
return true; // ja
} else {
return false; // nein
}
}
public void createNewDatabase() { // erstellt eine neue datenbank
try (Connection conn = DriverManager.getConnection(url)) {
DatabaseMetaData meta = conn.getMetaData();
} catch(SQLException e) {
e.printStackTrace();
}
}
}

View file

@ -4,6 +4,7 @@ public class FirstlaunchMain {
public void main() {
}
}

View file

@ -7,6 +7,7 @@ import javax.swing.UnsupportedLookAndFeelException;
import api.GetApiData;
import data.FetchData;
import data.ManageFiles;
import database.DatabaseManager;
import filestructure.CreateFileStructure;
import gui.LoadMenu;
@ -27,10 +28,15 @@ public class Main {
FetchData fetch = new FetchData();
fetch.getGithubString();
load.updateBar("Liste wird auf Updates geprüft...");
load.updateBar("Einträge werden Indexiert...");
ManageFiles manager = new ManageFiles();
manager.compareArrays();
manager.compareArrays();
load.updateBar("Datenbank wird geladen...");
DatabaseManager data = new DatabaseManager();
data.manage();
load.updateBar("Ladevorgang abgeschlossen");
load.close();

View file

@ -32,13 +32,13 @@ public class PlaySong {
}
private void playSong(String path) {
String filePath = path; // Passe den Pfad zu deiner MP3-Datei an
String filePath = path;
try {
FileInputStream fis = new FileInputStream(filePath);
AdvancedPlayer player = new AdvancedPlayer(fis);
// Starte das Abspielen in einem neuen Thread, damit der Hauptthread nicht blockiert wird
Thread playerThread = new Thread(() -> {
try {
player.play();
@ -49,16 +49,15 @@ public class PlaySong {
playerThread.start();
// Gib dem Player Zeit, die MP3-Datei abzuspielen
Thread.sleep(10000); // Zum Beispiel 10 Sekunden abwarten
// Beende den Player und schließe die FileInputStream
Thread.sleep(10000);
player.close();
fis.close();
} catch (FileNotFoundException | JavaLayerException | InterruptedException e) {
} catch (IOException | JavaLayerException | InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

View file

@ -13,4 +13,5 @@
requires jdash.client;
requires jdash.common;
requires jlayer;
requires java.sql;
}