Skip to content

Commit

Permalink
Fall back to timestamp if date is not a SQL date
Browse files Browse the repository at this point in the history
  • Loading branch information
pop4959 committed Sep 17, 2024
1 parent 49a0598 commit 4102af8
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLDataException;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
Expand Down Expand Up @@ -106,6 +108,12 @@ private MemoryStore convert() {
}
final ResultSet protectionSet = statement.executeQuery(Statements.LWC_SELECT_ALL_PROTECTIONS.get(configuration.type()).formatted(configuration.prefix()));
while (protectionSet.next()) {
Date date;
try {
date = protectionSet.getDate("date");
} catch (final SQLDataException e) {
date = new Date(protectionSet.getInt("date"));
}
protections.add(new Protection(
protectionSet.getInt("id"),
protectionSet.getString("owner"),
Expand All @@ -117,7 +125,7 @@ private MemoryStore convert() {
protectionSet.getInt("blockId"),
protectionSet.getString("world"),
protectionSet.getString("password"),
protectionSet.getDate("date"),
date,
protectionSet.getLong("last_accessed")
));
}
Expand Down

0 comments on commit 4102af8

Please sign in to comment.