|
@ -9,6 +9,10 @@ import java.sql.Statement; |
|
|
public class Games { |
|
|
public class Games { |
|
|
private String databaseURL = "jdbc:ucanaccess://GamesDB.accdb"; |
|
|
private String databaseURL = "jdbc:ucanaccess://GamesDB.accdb"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Checks if the connection to the database can be established |
|
|
|
|
|
* @return Returns true if it connects successfully and false if the connection fails. |
|
|
|
|
|
*/ |
|
|
public boolean checkConnection() { |
|
|
public boolean checkConnection() { |
|
|
try { |
|
|
try { |
|
|
Connection connection = DriverManager.getConnection(databaseURL); |
|
|
Connection connection = DriverManager.getConnection(databaseURL); |
|
@ -21,6 +25,10 @@ public class Games { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Prints the whole table for those, who cannot access the Database for some reason. |
|
|
|
|
|
* @return Returns a String of the whole table. |
|
|
|
|
|
*/ |
|
|
public String printTable() { |
|
|
public String printTable() { |
|
|
String result = ""; |
|
|
String result = ""; |
|
|
String query = "SELECT * FROM Games"; |
|
|
String query = "SELECT * FROM Games"; |
|
|