@ -9,7 +9,7 @@ import java.sql.Statement;
public class Games {
public class Games {
private String databaseURL = "jdbc:ucanaccess://GamesDB.accdb" ;
private String databaseURL = "jdbc:ucanaccess://GamesDB.accdb" ;
public boolean checkFor Connection ( ) {
public boolean checkConnection ( ) {
try {
try {
Connection connection = DriverManager . getConnection ( databaseURL ) ;
Connection connection = DriverManager . getConnection ( databaseURL ) ;
@ -21,7 +21,7 @@ public class Games {
}
}
}
}
public String checkFor Consoles ( ) {
public String checkConsoles ( ) {
String result = "" ;
String result = "" ;
String query = "SELECT Game_Console FROM Games" ;
String query = "SELECT Game_Console FROM Games" ;
boolean ninSwitch = false ;
boolean ninSwitch = false ;
@ -71,4 +71,70 @@ public class Games {
/ / The substring removes the last New line in the String .
/ / The substring removes the last New line in the String .
return result . substring ( 0 , result . length ( ) - 2 ) ;
return result . substring ( 0 , result . length ( ) - 2 ) ;
}
}
public String checkAllSamePublishers ( ) {
String result = "" ;
String query = "SELECT Game_Name, Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA FROM Games" ;
try {
Connection connection = DriverManager . getConnection ( databaseURL ) ;
Statement statement = connection . createStatement ( ) ;
ResultSet resultSet = statement . executeQuery ( query ) ;
while ( resultSet . next ( ) ) {
String gameName = resultSet . getString ( "Game_Name" ) ;
String gamePublisherEu = resultSet . getString ( "Game_Publisher_EU" ) ;
String gamePublisherJp = resultSet . getString ( "Game_Publisher_JP" ) ;
String gamePublisherNa = resultSet . getString ( "Game_Publisher_NA" ) ;
if ( gamePublisherEu . equals ( gamePublisherJp ) & & gamePublisherJp . equals ( gamePublisherNa ) & & gamePublisherEu . equals ( gamePublisherNa ) ) {
result + = gameName + ", " ;
}
}
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 ( ) - 2 ) ;
}
public String checkAllDifferentPublishers ( ) {
String result = "" ;
String query = "SELECT Game_Name, Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA FROM Games" ;
try {
Connection connection = DriverManager . getConnection ( databaseURL ) ;
Statement statement = connection . createStatement ( ) ;
ResultSet resultSet = statement . executeQuery ( query ) ;
while ( resultSet . next ( ) ) {
String gameName = resultSet . getString ( "Game_Name" ) ;
String gamePublisherEu = resultSet . getString ( "Game_Publisher_EU" ) ;
String gamePublisherJp = resultSet . getString ( "Game_Publisher_JP" ) ;
String gamePublisherNa = resultSet . getString ( "Game_Publisher_NA" ) ;
if ( ! gamePublisherEu . equals ( gamePublisherJp ) & & ! gamePublisherJp . equals ( gamePublisherNa ) & & ! gamePublisherEu . equals ( gamePublisherNa ) ) {
result + = gameName + ", " ;
}
}
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 ( ) - 2 ) ;
}
}
}