Fix
This commit is contained in:
parent
b57c10b6ca
commit
40c7acb3cc
1 changed files with 19 additions and 14 deletions
|
@ -3,24 +3,29 @@ package krusty;
|
||||||
import spark.Request;
|
import spark.Request;
|
||||||
import spark.Response;
|
import spark.Response;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.sql.Connection;
|
||||||
import java.util.Map;
|
import java.sql.DriverManager;
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
import static krusty.Jsonizer.toJson;
|
|
||||||
|
|
||||||
public class Database {
|
public class Database {
|
||||||
/**
|
private static final String jdbcString = "jdbc:sqlite:krusty.sqlite";
|
||||||
* 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>";
|
|
||||||
|
|
||||||
public void connect() {
|
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!
|
// TODO: Implement and change output in all methods below!
|
||||||
|
|
Loading…
Reference in a new issue