started working on new database system using sqlite
This commit is contained in:
parent
bcf0e75db1
commit
005758c1e5
8 changed files with 81 additions and 19 deletions
11
pom.xml
11
pom.xml
|
@ -37,11 +37,22 @@
|
||||||
<artifactId>jdash-client</artifactId>
|
<artifactId>jdash-client</artifactId>
|
||||||
<version>4.0.5</version>
|
<version>4.0.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.xerial</groupId>
|
||||||
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
|
<version>3.45.2.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javazoom</groupId>
|
<groupId>javazoom</groupId>
|
||||||
<artifactId>jlayer</artifactId>
|
<artifactId>jlayer</artifactId>
|
||||||
<version>1.0.1</version>
|
<version>1.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<version>1.2.10</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
package data;
|
|
||||||
|
|
||||||
public class FetchGDData {
|
|
||||||
|
|
||||||
public void getSongData() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
15
src/database/DatabaseManager.java
Normal file
15
src/database/DatabaseManager.java
Normal 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
38
src/database/Sqlite.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ public class FirstlaunchMain {
|
||||||
|
|
||||||
public void main() {
|
public void main() {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import javax.swing.UnsupportedLookAndFeelException;
|
||||||
import api.GetApiData;
|
import api.GetApiData;
|
||||||
import data.FetchData;
|
import data.FetchData;
|
||||||
import data.ManageFiles;
|
import data.ManageFiles;
|
||||||
|
import database.DatabaseManager;
|
||||||
import filestructure.CreateFileStructure;
|
import filestructure.CreateFileStructure;
|
||||||
import gui.LoadMenu;
|
import gui.LoadMenu;
|
||||||
|
|
||||||
|
@ -27,10 +28,15 @@ public class Main {
|
||||||
FetchData fetch = new FetchData();
|
FetchData fetch = new FetchData();
|
||||||
fetch.getGithubString();
|
fetch.getGithubString();
|
||||||
|
|
||||||
load.updateBar("Liste wird auf Updates geprüft...");
|
load.updateBar("Einträge werden Indexiert...");
|
||||||
|
|
||||||
ManageFiles manager = new ManageFiles();
|
ManageFiles manager = new ManageFiles();
|
||||||
manager.compareArrays();
|
manager.compareArrays();
|
||||||
|
|
||||||
|
load.updateBar("Datenbank wird geladen...");
|
||||||
|
|
||||||
|
DatabaseManager data = new DatabaseManager();
|
||||||
|
data.manage();
|
||||||
|
|
||||||
load.updateBar("Ladevorgang abgeschlossen");
|
load.updateBar("Ladevorgang abgeschlossen");
|
||||||
load.close();
|
load.close();
|
||||||
|
|
|
@ -32,13 +32,13 @@ public class PlaySong {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playSong(String path) {
|
private void playSong(String path) {
|
||||||
String filePath = path; // Passe den Pfad zu deiner MP3-Datei an
|
String filePath = path;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileInputStream fis = new FileInputStream(filePath);
|
FileInputStream fis = new FileInputStream(filePath);
|
||||||
AdvancedPlayer player = new AdvancedPlayer(fis);
|
AdvancedPlayer player = new AdvancedPlayer(fis);
|
||||||
|
|
||||||
// Starte das Abspielen in einem neuen Thread, damit der Hauptthread nicht blockiert wird
|
|
||||||
Thread playerThread = new Thread(() -> {
|
Thread playerThread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
player.play();
|
player.play();
|
||||||
|
@ -49,16 +49,15 @@ public class PlaySong {
|
||||||
|
|
||||||
playerThread.start();
|
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();
|
player.close();
|
||||||
fis.close();
|
fis.close();
|
||||||
} catch (FileNotFoundException | JavaLayerException | InterruptedException e) {
|
} catch (IOException | JavaLayerException | InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,4 +13,5 @@
|
||||||
requires jdash.client;
|
requires jdash.client;
|
||||||
requires jdash.common;
|
requires jdash.common;
|
||||||
requires jlayer;
|
requires jlayer;
|
||||||
|
requires java.sql;
|
||||||
}
|
}
|
Loading…
Reference in a new issue