mirror of
https://github.com/praktimarc/kst4contest.git
synced 2026-03-30 04:31:04 +02:00
changed way of db init
This commit is contained in:
@@ -27,7 +27,8 @@ public class DBController {
|
|||||||
private static final DBController dbcontroller = new DBController();
|
private static final DBController dbcontroller = new DBController();
|
||||||
private static Connection connection;
|
private static Connection connection;
|
||||||
// private static final String DB_PATH = System.getProperty("praktiKST.db");
|
// private static final String DB_PATH = System.getProperty("praktiKST.db");
|
||||||
private static final String DB_PATH = ApplicationFileUtils.getFilePath(ApplicationConstants.APPLICATION_NAME, DATABASE_FILE);
|
private static String DB_PATH = ApplicationFileUtils.getFilePath(ApplicationConstants.APPLICATION_NAME, DATABASE_FILE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -71,7 +72,17 @@ public class DBController {
|
|||||||
if (connection != null)
|
if (connection != null)
|
||||||
return;
|
return;
|
||||||
System.out.println("Creating Connection to Database...");
|
System.out.println("Creating Connection to Database...");
|
||||||
connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH);
|
|
||||||
|
DB_PATH = ApplicationFileUtils.getFilePath(ApplicationConstants.APPLICATION_NAME, DATABASE_FILE);
|
||||||
|
connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH);
|
||||||
|
|
||||||
|
//connection = DriverManager.getConnection("jdbc:sqlite:" + "C:\\Users\\prakt\\.praktiKST\\praktiKST.db");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("[DBH, Info]: Path = " + DB_PATH);
|
||||||
|
|
||||||
if (!connection.isClosed())
|
if (!connection.isClosed())
|
||||||
System.out.println("...Connection established");
|
System.out.println("...Connection established");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -91,6 +102,8 @@ public class DBController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void handleDB() {
|
// private void handleDB() {
|
||||||
|
|||||||
15
src/test/java/kst4contest/test/TestApplicationFileUtils.java
Normal file
15
src/test/java/kst4contest/test/TestApplicationFileUtils.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package kst4contest.test;
|
||||||
|
|
||||||
|
import kst4contest.ApplicationConstants;
|
||||||
|
import kst4contest.utils.ApplicationFileUtils;
|
||||||
|
|
||||||
|
public class TestApplicationFileUtils {
|
||||||
|
public static final String DATABASE_FILE = "praktiKST.db";
|
||||||
|
private static final String DB_PATH = ApplicationFileUtils.getFilePath(ApplicationConstants.APPLICATION_NAME, DATABASE_FILE);
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
System.out.println("DB Path = " + DB_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
33
src/test/java/kst4contest/test/TestDBController.java
Normal file
33
src/test/java/kst4contest/test/TestDBController.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package kst4contest.test;
|
||||||
|
|
||||||
|
import kst4contest.ApplicationConstants;
|
||||||
|
import kst4contest.controller.DBController;
|
||||||
|
import kst4contest.controller.Utils4KST;
|
||||||
|
import kst4contest.model.ChatMember;
|
||||||
|
import kst4contest.utils.ApplicationFileUtils;
|
||||||
|
|
||||||
|
public class TestDBController {
|
||||||
|
|
||||||
|
public static final String DATABASE_FILE = "praktiKST.db";
|
||||||
|
private static final String DB_PATH = ApplicationFileUtils.getFilePath(ApplicationConstants.APPLICATION_NAME, DATABASE_FILE);
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
|
||||||
|
DBController dbc = DBController.getInstance();
|
||||||
|
// dbc.initDBConnection();
|
||||||
|
|
||||||
|
ChatMember dummy = new ChatMember();
|
||||||
|
dummy.setCallSign("DM5M");
|
||||||
|
dummy.setQra("jo51ij");
|
||||||
|
dummy.setName("Team Test");
|
||||||
|
dummy.setLastActivity(new Utils4KST().time_generateActualTimeInDateFormat());
|
||||||
|
dummy.setWorked5600(true);
|
||||||
|
// dummy.setWorked432(true);
|
||||||
|
|
||||||
|
dbc.fetchChatMemberWkdDataForOnlyOneCallsignFromDB(dummy);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user