MrTigreroux / TigerReports

Spigot plugin to manage player reports.
16 stars 17 forks source link

MySQL connection issue #138

Closed reussy closed 1 year ago

reussy commented 1 year ago

I am unable to connect to the database (only happens with this plugin).

https://paste.helpch.at/esiqivuyim.md

MrTigreroux commented 1 year ago

Hello, it seems that your database name (not the Host IP) is incorrect. Check that you put the right name for MySQL: Database setting in config.yml file of TigerReports plugin.

reussy commented 1 year ago

Thank you for your answer,

The database name is the same as the one I created. I tried to create a new one, grant all privileges and it still gives the same error.

https://paste.helpch.at/ketohecume.sql

MrTigreroux commented 1 year ago

Can I see a screenshot of the MySQL part of your config.yml file please (hiding login and password) ? In what format did you encode your config.yml file ? What is the name of the database to use for TigerReports (I see 2 names in your link) ? What version of Minecraft do your server uses (/icanhasbukkit command to see it) ? What version of TigerReports do you use ?

reussy commented 1 year ago

Can I see a screenshot of the MySQL part of your config.yml file please (hiding login and password) ? In what format did you encode your config.yml file ? What is the name of the database to use for TigerReports (I see 2 names in your link) ? What version of Minecraft do your server uses (/icanhasbukkit command to see it) ? What version of TigerReports do you use ?

MySQL credentials: image

Encoding: UTF-8

I tried with both databases, none resulted.

Server Version: https://paste.helpch.at/taxolabeji.md

TigerReports Version: Latest (https://paste.helpch.at/rihagucowa.md)

Please note that in other plugins (including my own) I don't have this problem.

MrTigreroux commented 1 year ago

To be honest I don't have much experience with databases. What you can try is to replace "localhost" by "127.0.0.1". Is it always the same error ? (can I see it again without the "HIDE" that is useless (the name of the database is not confidential) ?). Just in case, you should restart your server and not use commands like /reload. As you said that you made plugins using a database, I let you have a look at how the database connection is opened here: https://github.com/MrTigreroux/TigerReports/blob/82826296ca4fa72add5c3a06aa66e3b1487bc01e/src/main/java/fr/mrtigreroux/tigerreports/data/database/MySQL.java#LL42C23-L42C23 If you see something that could be changed let me know. What you can finally try is to setup a real MySQL database, and not a MariaDB one.

reussy commented 1 year ago

To be honest I don't have much experience with databases. What you can try is to replace "localhost" by "127.0.0.1". Is it always the same error ? (can I see it again without the "HIDE" that is useless (the name of the database is not confidential) ?). Just in case, you should restart your server and not use commands like /reload. As you said that you made plugins using a database, I let you have a look at how the database connection is opened here: https://github.com/MrTigreroux/TigerReports/blob/82826296ca4fa72add5c3a06aa66e3b1487bc01e/src/main/java/fr/mrtigreroux/tigerreports/data/database/MySQL.java#LL42C23-L42C23 If you see something that could be changed let me know. What you can finally try is to setup a real MySQL database, and not a MariaDB one.

Thanks for replying,

It doesn't work using different host, I have tried even with the IP of my machine. I am not hiding the database, only the user and password which are confidential. I don't use /reload, the server starts cleanly.

I am going check the code and maybe I'll find something that is failing for my case. As for switching to "MySQL" it is not possible since MariaDB is a database management system derived from MySQL.

reussy commented 1 year ago

Perhaps you can try using this URL in the code

DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + "?useSSL=" + useSsl
                            + "&verifyServerCertificate=" + verifyServerCertificate + "&autoReconnect=true", username, password);
MrTigreroux commented 1 year ago

Hello, thank you for the help but I prefer to keep the default settings as they are. Therefore I added a way to configure a custom JDBC url in the new version 5.2.1. Please let me know if it doesn't fix your issue. Thank you again for reporting the problem, have a good day.

reussy commented 1 year ago

Only for future readers with this problem or similar.

If you are using MySQL 5.7 to 6.1 I recommend using the driver class name "com.mysql.cj.jdbc.Driver" instead of the default, that's all ✨.

Custom:
    DriverClassName: "com.mysql.cj.jdbc.Driver"

Thank you @MrTigreroux for your time.