Make SQLException reporting more verbose

This commit is contained in:
Mike Primm 2022-01-18 21:57:48 -06:00
parent 04104d125c
commit 4268b0b6c8
4 changed files with 70 additions and 58 deletions

View File

@ -3,6 +3,7 @@ package org.dynmap.storage;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.zip.CRC32;
@ -456,4 +457,15 @@ public abstract class MapStorage {
public void setLoginEnabled(DynmapCore core) {
}
public void logSQLException(String opmsg, SQLException x) {
Log.severe("SQLException: " + opmsg);
Log.severe(" ErrorCode: " + x.getErrorCode() + ", SQLState=" + x.getSQLState());
Log.severe(" Message: " + x.getMessage());
Throwable cause = x.getCause();
while (cause != null) {
Log.severe(" CausedBy: " + cause.getMessage());
cause = cause.getCause();
}
}
}

View File

@ -83,7 +83,7 @@ public class MySQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Tile exists error - " + x.getMessage());
logSQLException("Tile exists error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -108,7 +108,7 @@ public class MySQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Tile matches hash error - " + x.getMessage());
logSQLException("Tile matches hash error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -137,7 +137,7 @@ public class MySQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Tile read error - " + x.getMessage());
logSQLException("Tile read error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -193,7 +193,7 @@ public class MySQLMapStorage extends MapStorage {
world.enqueueZoomOutUpdate(this);
}
} catch (SQLException x) {
Log.severe("Tile write error - " + x.getMessage());
logSQLException("Tile write error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -412,7 +412,7 @@ public class MySQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Error loading map table - " + x.getMessage());
logSQLException("Error loading map table", x);
err = true;
} finally {
releaseConnection(c, err);
@ -451,7 +451,7 @@ public class MySQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Error updating Maps table - " + x.getMessage());
logSQLException("Error updating Maps table", x);
err = true;
} finally {
releaseConnection(c, err);
@ -481,7 +481,7 @@ public class MySQLMapStorage extends MapStorage {
doUpdate(c, "INSERT INTO " + tableSchemaVersion + " (level) VALUES (4)");
version = 4; // Initial - we have all the following updates already
} catch (SQLException x) {
Log.severe("Error creating tables - " + x.getMessage());
logSQLException("Error creating tables", x);
err = true;
return false;
} finally {
@ -498,7 +498,7 @@ public class MySQLMapStorage extends MapStorage {
doUpdate(c, "UPDATE " + tableSchemaVersion + " SET level=2 WHERE level = 1;");
version = 2;
} catch (SQLException x) {
Log.severe("Error creating tables - " + x.getMessage());
logSQLException("Error updating tables to version=1", x);
err = true;
return false;
} finally {
@ -516,7 +516,7 @@ public class MySQLMapStorage extends MapStorage {
doUpdate(c, "UPDATE " + tableSchemaVersion + " SET level=3 WHERE level = 2;");
version = 3;
} catch (SQLException x) {
Log.severe("Error creating tables - " + x.getMessage());
logSQLException("Error updating tables to version=2", x);
err = true;
return false;
} finally {
@ -534,7 +534,7 @@ public class MySQLMapStorage extends MapStorage {
doUpdate(c, "UPDATE " + tableSchemaVersion + " SET level=4 WHERE level = 3;");
version = 4;
} catch (SQLException x) {
Log.severe("Error creating tables - " + x.getMessage());
logSQLException("Error updating tables to version=3", x);
err = true;
return false;
} finally {
@ -718,7 +718,7 @@ public class MySQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Tile enum error - " + x.getMessage());
logSQLException("Tile enum error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -756,7 +756,7 @@ public class MySQLMapStorage extends MapStorage {
}
stmt.close();
} catch (SQLException x) {
Log.severe("Tile purge error - " + x.getMessage());
logSQLException("Tile purge error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -795,7 +795,7 @@ public class MySQLMapStorage extends MapStorage {
stmt.executeUpdate();
stmt.close();
} catch (SQLException x) {
Log.severe("Face write error - " + x.getMessage());
logSQLException("Face write error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -822,7 +822,7 @@ public class MySQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Face read error - " + x.getMessage());
logSQLException("Face reqd error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -847,7 +847,7 @@ public class MySQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Face exists error - " + x.getMessage());
logSQLException("Face exists error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -894,7 +894,7 @@ public class MySQLMapStorage extends MapStorage {
}
stmt.executeUpdate();
} catch (SQLException x) {
Log.severe("Marker write error - " + x.getMessage());
logSQLException("Marker write error", x);
err = true;
} finally {
if (rs != null) { try { rs.close(); } catch (SQLException sx) {} }
@ -921,7 +921,7 @@ public class MySQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Marker read error - " + x.getMessage());
logSQLException("Marker read error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -967,7 +967,7 @@ public class MySQLMapStorage extends MapStorage {
}
stmt.executeUpdate();
} catch (SQLException x) {
Log.severe("Marker file write error - " + x.getMessage());
logSQLException("Marker file write error", x);
err = true;
} finally {
if (rs != null) { try { rs.close(); } catch (SQLException sx) {} }
@ -994,7 +994,7 @@ public class MySQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Marker file read error - " + x.getMessage());
logSQLException("Marker file read error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -1050,7 +1050,7 @@ public class MySQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Standalone file read error - " + x.getMessage());
logSQLException("Standalone file read error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -1100,7 +1100,7 @@ public class MySQLMapStorage extends MapStorage {
}
stmt.executeUpdate();
} catch (SQLException x) {
Log.severe("Standalone file write error - " + x.getMessage());
logSQLException("Standalone file write error", x);
err = true;
} finally {
if (rs != null) { try { rs.close(); } catch (SQLException sx) {} }

View File

@ -86,7 +86,7 @@ public class PostgreSQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Tile exists error - " + x.getMessage());
logSQLException("Tile exists error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -111,7 +111,7 @@ public class PostgreSQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Tile matches hash error - " + x.getMessage());
logSQLException("Tile matches hash error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -140,7 +140,7 @@ public class PostgreSQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Tile read error - " + x.getMessage());
logSQLException("Tile read error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -196,7 +196,7 @@ public class PostgreSQLMapStorage extends MapStorage {
world.enqueueZoomOutUpdate(this);
}
} catch (SQLException x) {
Log.severe("Tile write error - " + x.getMessage());
logSQLException("Tile write error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -398,7 +398,7 @@ public class PostgreSQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Error loading map table - " + x.getMessage());
logSQLException("Error loading map table", x);
err = true;
} finally {
releaseConnection(c, err);
@ -437,7 +437,7 @@ public class PostgreSQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Error updating Maps table - " + x.getMessage());
logSQLException("Error updating Maps table", x);
err = true;
} finally {
releaseConnection(c, err);
@ -467,7 +467,7 @@ public class PostgreSQLMapStorage extends MapStorage {
doUpdate(c, "INSERT INTO " + tableSchemaVersion + " (level) VALUES (3)");
version = 3; // initialzed to current schema
} catch (SQLException x) {
Log.severe("Error creating tables - " + x.getMessage());
logSQLException("Error creating tables", x);
err = true;
return false;
} finally {
@ -484,7 +484,7 @@ public class PostgreSQLMapStorage extends MapStorage {
doUpdate(c, "UPDATE " + tableSchemaVersion + " SET level=2 WHERE level = 1;");
version = 2;
} catch (SQLException x) {
Log.severe("Error creating tables - " + x.getMessage());
logSQLException("Error upgrading tables to version=2", x);
err = true;
return false;
} finally {
@ -502,7 +502,7 @@ public class PostgreSQLMapStorage extends MapStorage {
doUpdate(c, "UPDATE " + tableSchemaVersion + " SET level=3 WHERE level = 2;");
version = 3;
} catch (SQLException x) {
Log.severe("Error creating tables - " + x.getMessage());
logSQLException("Error upgrading tables to version=3", x);
err = true;
return false;
} finally {
@ -668,7 +668,7 @@ public class PostgreSQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Tile enum error - " + x.getMessage());
logSQLException("Tile enum error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -722,7 +722,7 @@ public class PostgreSQLMapStorage extends MapStorage {
stmt.executeUpdate("DELETE FROM " + tableTiles + " WHERE MapID=" + mapkey + ";");
stmt.close();
} catch (SQLException x) {
Log.severe("Tile purge error - " + x.getMessage());
logSQLException("Tile purge error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -761,7 +761,7 @@ public class PostgreSQLMapStorage extends MapStorage {
stmt.executeUpdate();
stmt.close();
} catch (SQLException x) {
Log.severe("Face write error - " + x.getMessage());
logSQLException("Face write error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -788,7 +788,7 @@ public class PostgreSQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Face read error - " + x.getMessage());
logSQLException("Face read error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -813,7 +813,7 @@ public class PostgreSQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Face exists error - " + x.getMessage());
logSQLException("Face exists error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -860,7 +860,7 @@ public class PostgreSQLMapStorage extends MapStorage {
}
stmt.executeUpdate();
} catch (SQLException x) {
Log.severe("Marker write error - " + x.getMessage());
logSQLException("Marker write error", x);
err = true;
} finally {
if (rs != null) { try { rs.close(); } catch (SQLException sx) {} }
@ -887,7 +887,7 @@ public class PostgreSQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Marker read error - " + x.getMessage());
logSQLException("Marker read error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -933,7 +933,7 @@ public class PostgreSQLMapStorage extends MapStorage {
}
stmt.executeUpdate();
} catch (SQLException x) {
Log.severe("Marker file write error - " + x.getMessage());
logSQLException("Marker file write error", x);
err = true;
} finally {
if (rs != null) { try { rs.close(); } catch (SQLException sx) {} }
@ -960,7 +960,7 @@ public class PostgreSQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Marker file read error - " + x.getMessage());
logSQLException("Marker file read error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -1016,7 +1016,7 @@ public class PostgreSQLMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Standalone file read error - " + x.getMessage());
logSQLException("Standalone file read error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -1066,7 +1066,7 @@ public class PostgreSQLMapStorage extends MapStorage {
}
stmt.executeUpdate();
} catch (SQLException x) {
Log.severe("Standalone file write error - " + x.getMessage());
logSQLException("Standalone file write error", x);
err = true;
} finally {
if (rs != null) { try { rs.close(); } catch (SQLException sx) {} }

View File

@ -68,7 +68,7 @@ public class SQLiteMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Tile exists error - " + x.getMessage());
logSQLException("Tile exists error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -94,7 +94,7 @@ public class SQLiteMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Tile matches hash error - " + x.getMessage());
logSQLException("Tile matches hash error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -130,7 +130,7 @@ public class SQLiteMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Tile read error - " + x.getMessage());
logSQLException("Tile read error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -189,7 +189,7 @@ public class SQLiteMapStorage extends MapStorage {
world.enqueueZoomOutUpdate(this);
}
} catch (SQLException x) {
Log.severe("Tile write error - " + x.getMessage());
logSQLException("Tile write error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -337,7 +337,7 @@ public class SQLiteMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Error loading map table - " + x.getMessage());
logSQLException("Error loading map table", x);
err = true;
} finally {
releaseConnection(c, err);
@ -376,7 +376,7 @@ public class SQLiteMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Error updating Maps table - " + x.getMessage());
logSQLException("Error updating Maps table", x);
err = true;
} finally {
releaseConnection(c, err);
@ -405,7 +405,7 @@ public class SQLiteMapStorage extends MapStorage {
doUpdate(c, "INSERT INTO SchemaVersion (level) VALUES (2)");
version = 2; // Initializes to current schema
} catch (SQLException x) {
Log.severe("Error creating tables - " + x.getMessage());
logSQLException("Error creating tables", x);
err = true;
return false;
} finally {
@ -423,7 +423,7 @@ public class SQLiteMapStorage extends MapStorage {
doUpdate(c, "UPDATE SchemaVersion SET level=2");
version = 2;
} catch (SQLException x) {
Log.severe("Error creating tables - " + x.getMessage());
logSQLException("Error updating tables to version=2", x);
err = true;
return false;
} finally {
@ -612,7 +612,7 @@ public class SQLiteMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Tile enum error - " + x.getMessage());
logSQLException("Tile enum error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -649,7 +649,7 @@ public class SQLiteMapStorage extends MapStorage {
doExecuteUpdate(stmt, "DELETE FROM Tiles WHERE MapID=" + mapkey + ";");
stmt.close();
} catch (SQLException x) {
Log.severe("Tile purge error - " + x.getMessage());
logSQLException("Tile purge error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -691,7 +691,7 @@ public class SQLiteMapStorage extends MapStorage {
doExecuteUpdate(stmt);
stmt.close();
} catch (SQLException x) {
Log.severe("Face write error - " + x.getMessage());
logSQLException("Face write error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -725,7 +725,7 @@ public class SQLiteMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Face read error - " + x.getMessage());
logSQLException("Face read error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -751,7 +751,7 @@ public class SQLiteMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Face exists error - " + x.getMessage());
logSQLException("Face exists error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -802,7 +802,7 @@ public class SQLiteMapStorage extends MapStorage {
stmt.close();
stmt = null;
} catch (SQLException x) {
Log.severe("Marker write error - " + x.getMessage());
logSQLException("Marker write error", x);
err = true;
} finally {
if (rs != null) { try { rs.close(); } catch (SQLException sx) {} }
@ -836,7 +836,7 @@ public class SQLiteMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Marker read error - " + x.getMessage());
logSQLException("Marker read error", x);
err = true;
} finally {
releaseConnection(c, err);
@ -883,7 +883,7 @@ public class SQLiteMapStorage extends MapStorage {
//stmt.executeUpdate();
doExecuteUpdate(stmt);
} catch (SQLException x) {
Log.severe("Marker file write error - " + x.getMessage());
logSQLException("Marker file write error", x);
err = true;
} finally {
if (rs != null) { try { rs.close(); } catch (SQLException sx) {} }
@ -911,7 +911,7 @@ public class SQLiteMapStorage extends MapStorage {
rs.close();
stmt.close();
} catch (SQLException x) {
Log.severe("Marker file read error - " + x.getMessage());
logSQLException("Marker file read error", x);
err = true;
} finally {
releaseConnection(c, err);