Otettu Path.of() käyttöön tiedostojen luvussa (käyttöjärjestelmä riippumattomuus)
This commit is contained in:
@@ -6,23 +6,23 @@ import fi.lpam.Main;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Path;
|
||||
import java.sql.*;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Tietokanta {
|
||||
private static String osoite;
|
||||
private static String dbPath = SystemUtils.getUserHome().getAbsolutePath() + "\\OneDrive\\Kuljetusruokasovellus\\tietokanta.db";
|
||||
private static File tietokantatiedosto = Path.of(SystemUtils.getUserHome().getAbsolutePath(), "OneDrive", "Kuljetusruokasovellus", "tietokanta.db").toFile();
|
||||
|
||||
public Tietokanta(boolean dev) {
|
||||
if (dev) dbPath = "testikanta.db";
|
||||
File file = new File(dbPath);
|
||||
if (dev) tietokantatiedosto = new File("testikanta.db");
|
||||
try {
|
||||
boolean _ = file.getParentFile().mkdirs();
|
||||
boolean _ = file.createNewFile();
|
||||
boolean _ = tietokantatiedosto.getParentFile().mkdirs();
|
||||
boolean _ = tietokantatiedosto.createNewFile();
|
||||
}
|
||||
catch (Exception _) {}
|
||||
|
||||
osoite = "jdbc:sqlite:" + file.getAbsolutePath();
|
||||
osoite = "jdbc:sqlite:" + tietokantatiedosto.getAbsolutePath();
|
||||
|
||||
|
||||
try (Connection conn = haeYhteys()) {
|
||||
|
||||
Reference in New Issue
Block a user