chore/feat: log driver version on error

This commit is contained in:
Pierre Maurice Schwang 2023-10-06 13:26:33 +02:00
parent 2ffec0a3a5
commit ab246cd304

View File

@ -155,7 +155,8 @@ public class SQLManager implements AbstractDB {
this.worldConfiguration = worldConfiguration; this.worldConfiguration = worldConfiguration;
this.database = database; this.database = database;
this.connection = database.openConnection(); this.connection = database.openConnection();
this.supportsGetGeneratedKeys = this.connection.getMetaData().supportsGetGeneratedKeys(); final DatabaseMetaData databaseMetaData = this.connection.getMetaData();
this.supportsGetGeneratedKeys = databaseMetaData.supportsGetGeneratedKeys();
this.mySQL = database instanceof MySQL; this.mySQL = database instanceof MySQL;
this.globalTasks = new ConcurrentLinkedQueue<>(); this.globalTasks = new ConcurrentLinkedQueue<>();
this.notifyTasks = new ConcurrentLinkedQueue<>(); this.notifyTasks = new ConcurrentLinkedQueue<>();
@ -165,8 +166,10 @@ public class SQLManager implements AbstractDB {
this.prefix = prefix; this.prefix = prefix;
if (mySQL && !supportsGetGeneratedKeys) { if (mySQL && !supportsGetGeneratedKeys) {
String driver = databaseMetaData.getDriverName();
String driverVersion = databaseMetaData.getDriverVersion();
throw new SQLException("Database Driver for MySQL does not support Statement#getGeneratedKeys - which breaks " + throw new SQLException("Database Driver for MySQL does not support Statement#getGeneratedKeys - which breaks " +
"PlotSquared functionality"); "PlotSquared functionality (Using " + driver + ":" + driverVersion + ")");
} }
this.SET_OWNER = "UPDATE `" + this.prefix this.SET_OWNER = "UPDATE `" + this.prefix