xF3d33 / UltimateTeams

https://modrinth.com/plugin/ultimate-teams
GNU General Public License v3.0
5 stars 4 forks source link

SQLite database reconnecting every time it is written to, leading to console spam #19

Closed MinecraftMan1013number2 closed 2 months ago

MinecraftMan1013number2 commented 5 months ago

I don't know if this happens for MySQL as well, but for SQLite, it says that the database was connected to every single time something about the data is changed.

[Server] [INFO] UUID of player MinecraftMan1013 is 61f1144d-d9c3-45f3-bbd6-c700bc28fee0
[Server] [INFO] [UltimateTeams] Attempting to connect to database
[Server] [INFO] MinecraftMan1013 joined the game
[Server] [INFO] [UltimateTeams] SQLite Database Connected!
[Server] [INFO] [UltimateTeams] Attempting to connect to database
[Server] [INFO] [UltimateTeams] SQLite Database Connected!
[Connect] User MinecraftMan1013, IP <removed>
[Server] [INFO] MinecraftMan1013 issued server command: /team create test
[Server] [INFO] [UltimateTeams] Attempting to connect to database
[Server] [INFO] [UltimateTeams] SQLite Database Connected!
###### The team already exists, so nothing was changed which is why there is no message about the database ###### 
[Server] [INFO] MinecraftMan1013 issued server command: /team create test
[Server] [INFO] MinecraftMan1013 issued server command: /team disband
[Server] [INFO] MinecraftMan1013 issued server command: /team disband confirm
[Server] [INFO] [UltimateTeams] Attempting to connect to database
[Server] [INFO] [UltimateTeams] SQLite Database Connected!
MinecraftMan1013number2 commented 5 months ago

I did a little bit of testing by adding broadcasts to SQLiteDatabase#getConnection() as follows:

private Connection getConnection() throws SQLException {
        if (connection == null) {
            Bukkit.broadcastMessage("connection null");
            setConnection();
        } else if (connection.isClosed()) {
            Bukkit.broadcastMessage("connection closed");
            setConnection();
        }
        return connection;
    }

The result was this image

Somehow the connection is being closed,