fix bug in highscore

This commit is contained in:
TheCodeBoat 2013-07-05 08:27:33 +02:00
parent d6ceab8afb
commit 9c5a3b031f
2 changed files with 5 additions and 5 deletions

View File

@ -66,7 +66,7 @@ public class HighscoreManager {
try {
ResultSet rs = connector.excecuteQuery(connection, "SELECT * FROM Scores WHERE LOWER(SongName) LIKE LOWER('%" + songName + "%');");
while (rs.next()) {
tempScores.add(new Score(rs.getString("SongName"), rs.getString("Name"), rs.getInt("Points"), rs.getDate("Date")));
tempScores.add(new Score(rs.getString("SongName"), rs.getString("Name"), rs.getInt("Points"), DateFormat.getDateTimeInstance().parse(rs.getString("GameDate"))));
}
rs.close();
} catch (Exception ex) {
@ -79,7 +79,7 @@ public class HighscoreManager {
try {
ResultSet rs = connector.excecuteQuery(connection, "SELECT * FROM Scores;");
while (rs.next()) {
scores.add(new Score(rs.getString("SongName"), rs.getString("Name"), rs.getInt("Points"), rs.getDate("Date")));
scores.add(new Score(rs.getString("SongName"), rs.getString("Name"), rs.getInt("Points"), DateFormat.getDateTimeInstance().parse(rs.getString("GameDate"))));
}
rs.close();
} catch (Exception ex) {
@ -88,8 +88,8 @@ public class HighscoreManager {
private void updateScoreFile(String name, int score, String songName, Date date) {
try {
connector.excecuteUpdate(connection, "INSERT INTO Scores(Name,Points,SongName,Date) values('" + name + "'," + score + ", '" + songName + "', '" + DateFormat.getDateTimeInstance().format(date) + "' )");
connector.excecuteUpdate(connection, "INSERT INTO Scores(Name,Points,SongName,GameDate) values('" + name + "'," + score + ", '" + songName + "', '" + DateFormat.getDateTimeInstance().format(date) + "' )");
} catch (Exception ex) {
}
}
}
}

View File

@ -39,7 +39,7 @@ public class SQLiteConnector {
try {
Class.forName("org.sqlite.JDBC");
String sqliteTable = "CREATE TABLE Scores (Name VARCHAR(250), Points INT(20), SongName VARCHAR(250), Date datetime)";
String sqliteTable = "CREATE TABLE Scores (Name VARCHAR(250), Points INT(20), SongName VARCHAR(250), GameDate DATE)";
File sQLiteDb = new File(DB_PATH);
if (!sQLiteDb.exists()) {
sQLiteDb.createNewFile();