From 4caeda11ea78b39569f5b81ced79e1659a5a701b Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Sun, 13 Feb 2022 23:59:20 +0100 Subject: [PATCH] Added Function which prints out the list for users without MS Access --- projjpn/GamesDB.accdb | Bin 1015808 -> 1015808 bytes projjpn/GamesDB.laccdb | Bin 64 -> 0 bytes .../java/de/hs_fulda/ciip/projjpn/Games.java | 66 ++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/projjpn/GamesDB.accdb b/projjpn/GamesDB.accdb index 332543baa35d0f3bad171931a275406072b7362e..380bfb7e9108dd721ab2a676ca9268ab7e907647 100644 GIT binary patch delta 134 zcmZo@uxn_r+rY%fB*C&-fbRq2WCcE+CV_1Nj3@Y553({|oIm}n9HS&-So?E1Mj&Pa zVrC#_+5TLPReB+hB)3nPqYncRgfmPRIKVnNj!}})ul>0kBM>tI zF*6XeY=17tD!q_LliMfE(T4#D{28VT9AKTZeb)ij4{Q@R2(+&{&I-hAK+F!r96-zo U#9Tnk4a7V^%)5QnalWt}0AG+X-~a#s diff --git a/projjpn/GamesDB.laccdb b/projjpn/GamesDB.laccdb index 5a03e0388674df9c401c0cef4dc38d6267f63454..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 GIT binary patch literal 0 HcmV?d00001 literal 64 icmZ>94fYQ45771WG4%0wG-gmh1CA-VnRytZ2t@#)Zwp2M diff --git a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java index 370c05e..efbbe6e 100644 --- a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java +++ b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java @@ -21,6 +21,72 @@ public class Games { } } + public String printTable() { + String result = ""; + String query = "SELECT * FROM Games"; + + try { + Connection connection = DriverManager.getConnection(databaseURL); + + Statement statement = connection.createStatement(); + ResultSet resultSet = statement.executeQuery(query); + + while (resultSet.next()) { + int id = resultSet.getInt("Game_ID"); + String gameName = resultSet.getString("Game_Name"); + String gameConsole = resultSet.getString("Game_Console"); + String gameDeveloper = resultSet.getString("Game_Developer"); + String gamePublisherEu = resultSet.getString("Game_Developer"); + String gamePublisherJp = resultSet.getString("Game_Console"); + String gamePublisherNa = resultSet.getString("Game_Console"); + String gameGenre = resultSet.getString("Game_Genre"); + + String gameReleaseEu = resultSet.getString("Game_Release_EU"); + String gameReleaseEuDots = gameReleaseEu.substring(8, 10) + "." + gameReleaseEu.substring(5, 7) + + "." + gameReleaseEu.substring(0, 4); + + String gameReleaseJp = resultSet.getString("Game_Release_JP"); + String gameReleaseJpDots = gameReleaseJp.substring(8, 10) + "." + gameReleaseJp.substring(5, 7) + + "." + gameReleaseJp.substring(0, 4); + + String gameReleaseNa = resultSet.getString("Game_Release_NA"); + String gameReleaseNaDots = gameReleaseNa.substring(8, 10) + "." + gameReleaseNa.substring(5, 7) + + "." + gameReleaseNa.substring(0, 4); + String gameReleaseAu = resultSet.getString("Game_Release_AU"); + String gameReleaseAuDots; + if (gameReleaseAu != null) { + gameReleaseAuDots = gameReleaseAu.substring(8, 10) + "." + gameReleaseAu.substring(5, 7) + + "." + gameReleaseAu.substring(0, 4); + } else { + gameReleaseAuDots = "Unknown"; + } + + int gameUsk = resultSet.getInt("Game_USK_Rating"); + int gamePegi = resultSet.getInt("Game_PEGI_Rating"); + String gameEsrb = resultSet.getString("Game_ESRB_Rating"); + String gameCero = resultSet.getString("Game_CERO_Rating"); + String gameAcb = resultSet.getString("Game_ACB_Rating"); + String gamePlayers = resultSet.getString("Game_Players"); + + if (gamePegi != 0) { + result += id + ": " + gameName + ", " + gameConsole + ", " + gameDeveloper + ", " + gamePublisherEu + ", " + gamePublisherJp + ", " + gamePublisherNa + ", " + gameGenre + ", " + gameReleaseEuDots + ", " + gameReleaseJpDots + ", " + gameReleaseNaDots + ", " + gameReleaseAuDots + ", " + gameUsk + ", " + gamePegi + ", " + gameEsrb + ", " + gameCero + ", " + gameAcb + ", " + gamePlayers + "\n"; + } else { + result += id + ": " + gameName + ", " + gameConsole + ", " + gameDeveloper + ", " + gamePublisherEu + ", " + gamePublisherJp + ", " + gamePublisherNa + ", " + gameGenre + ", " + gameReleaseEuDots + ", " + gameReleaseJpDots + ", " + gameReleaseNaDots + ", " + gameReleaseAuDots + ", " + gameUsk + ", Unknown, " + gameEsrb + ", " + gameCero + ", " + gameAcb + ", " + gamePlayers + "\n"; + } + + + } + statement.close(); + + connection.close(); + + } catch (SQLException e) { + e.printStackTrace(); + } + // The substring removes the last New line in the String. + return result.substring(0, result.length() - 1); + } + public String checkGames() { String result = ""; String query = "SELECT Game_Name FROM Games";