mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Database copyTo improve
Former-commit-id: fc73a602da8abd276c5d55f9005bd67d76ed7d6e [formerly 3e4158982ea61b9bfd750acd56e8fd4f14845967] Former-commit-id: 6f9e1f51ab246a6db08bbf67c0ee5255edb96241
This commit is contained in:
1 parent
cc519c54d0
commit
05cbced04b
1 file changed
+13
-4
@@ -161,17 +161,26 @@ public class Database {
|
||||
rs.close();
|
||||
core.flush();
|
||||
// For each table
|
||||
String prefix = plugin.getConfig().getString("database.prefix");
|
||||
for (String table : tables) {
|
||||
String finalTable = null;
|
||||
if(table.startsWith(prefix)) {
|
||||
finalTable = table;
|
||||
}else {
|
||||
finalTable = prefix+table;
|
||||
plugin.getLogger().info("CovertHelper: Fixed table name from SQLite "+table+ " to MySQL "+finalTable);
|
||||
}
|
||||
|
||||
if (table.toLowerCase().startsWith("sqlite_autoindex_"))
|
||||
continue;
|
||||
plugin.getLogger().log(Level.WARNING, "Copying " + table);
|
||||
plugin.getLogger().log(Level.WARNING, "Copying " + finalTable);
|
||||
// Wipe the old records
|
||||
db.getConnection().prepareStatement("DELETE FROM " + table).execute();
|
||||
db.getConnection().prepareStatement("DELETE FROM " + finalTable).execute();
|
||||
// Fetch all the data from the existing database
|
||||
rs = getConnection().prepareStatement("SELECT * FROM " + table).executeQuery();
|
||||
rs = getConnection().prepareStatement("SELECT * FROM " + finalTable).executeQuery();
|
||||
int n = 0;
|
||||
// Build the query
|
||||
String query = "INSERT INTO " + table + " VALUES (";
|
||||
String query = "INSERT INTO " + finalTable + " VALUES (";
|
||||
// Append another placeholder for the value
|
||||
query += "?";
|
||||
for (int i = 2; i <= rs.getMetaData().getColumnCount(); i++) {
|
||||
|
||||
Reference in new issue
Block a user