This commit is contained in:
Imbus 2024-04-20 21:50:54 +02:00
parent b57c10b6ca
commit 40c7acb3cc

View file

@ -3,24 +3,29 @@ package krusty;
import spark.Request;
import spark.Response;
import java.util.Arrays;
import java.util.Map;
import java.util.TreeMap;
import static krusty.Jsonizer.toJson;
import java.sql.Connection;
import java.sql.DriverManager;
public class Database {
/**
* Modify it to fit your environment and then use this string when connecting to your database!
*/
private static final String jdbcString = "jdbc:mysql://localhost/krusty";
// For use with MySQL or PostgreSQL
private static final String jdbcUsername = "<CHANGE ME>";
private static final String jdbcPassword = "<CHANGE ME>";
private static final String jdbcString = "jdbc:sqlite:krusty.sqlite";
public void connect() {
// Connect to database here
Connection conn = null;
try {
conn = DriverManager.getConnection(jdbcString);
System.out.println("Connection to SQLite has been established.");
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
try {
if (conn != null) {
conn.close();
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
// TODO: Implement and change output in all methods below!