mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
check for table before checking for column to avoid "query doesn't return ResultSet"error
This commit is contained in:
parent
ba72865298
commit
a341eee92a
@ -379,15 +379,28 @@ public final class DrawableDB {
|
||||
}
|
||||
|
||||
private static boolean hasDataSourceObjIdColumn(Path dbPath) throws TskCoreException {
|
||||
String sql = "PRAGMA table_info('drawable_files')"; //NON-NLS
|
||||
try (Connection con = DriverManager.getConnection("jdbc:sqlite:" + dbPath.toString()); //NON-NLS
|
||||
Statement stmt = con.createStatement();
|
||||
ResultSet results = stmt.executeQuery(sql);) {
|
||||
Statement stmt = con.createStatement();) {
|
||||
boolean tableExists = false;
|
||||
try (ResultSet results = stmt.executeQuery("SELECT name FROM sqlite_master WHERE type='table'");) {//NON-NLS
|
||||
while (results.next()) {
|
||||
if ("drawable_files".equals(results.getString("name"))) {
|
||||
tableExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (false == tableExists) {
|
||||
return false;
|
||||
} else {
|
||||
try (ResultSet results = stmt.executeQuery("PRAGMA table_info('drawable_files')");) { //NON-NLS
|
||||
while (results.next()) {
|
||||
if ("data_source_obj_id".equals(results.getString("name"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException ex) {
|
||||
throw new TskCoreException("SQL error checking database compatibility", ex); //NON-NLS
|
||||
|
Loading…
x
Reference in New Issue
Block a user