Browse Source

Added Database Connection + Test

dev
Adem Berber 3 years ago
parent
commit
62217138e6
  1. BIN
      projjpn/GamesDB.accdb
  2. 0
      projjpn/GamesDB.laccdb
  3. 21
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  4. 11
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

BIN
projjpn/GamesDB.accdb

0
projjpn/GamesDB.laccdb

21
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java

@ -0,0 +1,21 @@
package de.hs_fulda.ciip.projjpn;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Games {
private String databaseURL = "jdbc:ucanaccess://GamesDB.accdb";
public boolean checkForConnection() {
try {
Connection connection = DriverManager.getConnection(databaseURL);
connection.close();
return true;
} catch (SQLException e) {
return false;
}
}
}

11
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

@ -0,0 +1,11 @@
package de.hs_fulda.ciip.projjpn;
import junit.framework.TestCase;
public class GamesTest extends TestCase {
public void test_checkForConnection() {
Games testObject = new Games();
boolean expected = true;
boolean actual = testObject.checkForConnection();
assertEquals(expected, actual);
}
}
Loading…
Cancel
Save