pavog / craftconomy3

An economy plugin for minecraftservers.
GNU Lesser General Public License v3.0
19 stars 8 forks source link

java.sql.SQLException: Cannot add foreign key constraint #108

Open eyebrawl123 opened 3 years ago

eyebrawl123 commented 3 years ago

[13:28:26] [Server thread/INFO]: [com.zaxxer.hikari.HikariDataSource] HikariPool-1 - Starting... [13:28:26] [Server thread/INFO]: [com.zaxxer.hikari.HikariDataSource] HikariPool-1 - Start completed. [13:28:26] [Server thread/WARN]: java.sql.SQLException: Cannot add foreign key constraint [13:28:26] [Server thread/WARN]: at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) [13:28:26] [Server thread/WARN]: at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) [13:28:26] [Server thread/WARN]: at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953) [13:28:26] [Server thread/WARN]: at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1092) [13:28:26] [Server thread/WARN]: at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1040) [13:28:26] [Server thread/WARN]: at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1347) [13:28:26] [Server thread/WARN]: at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:1025) [13:28:26] [Server thread/WARN]: at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61) [13:28:26] [Server thread/WARN]: at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java) [13:28:26] [Server thread/WARN]: at com.greatmancode.craftconomy3.storage.sql.MySQLEngine.(MySQLEngine.java:97) [13:28:26] [Server thread/WARN]: at com.greatmancode.craftconomy3.storage.StorageHandler.(StorageHandler.java:41) [13:28:26] [Server thread/WARN]: at com.greatmancode.craftconomy3.Common.initialiseDatabase(Common.java:361) [13:28:26] [Server thread/WARN]: at com.greatmancode.craftconomy3.Common.onEnable(Common.java:133) [13:28:26] [Server thread/WARN]: at com.greatmancode.craftconomy3.tools.interfaces.BukkitLoader.onEnable(BukkitLoader.java:53) [13:28:26] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) [13:28:26] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) [13:28:26] [Server thread/WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) [13:28:26] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:501) [13:28:26] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:415) [13:28:26] [Server thread/WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:591) [13:28:26] [Server thread/WARN]: at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:280) [13:28:26] [Server thread/WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1065) [13:28:26] [Server thread/WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) [13:28:26] [Server thread/WARN]: at java.lang.Thread.run(Thread.java:748)

This problem has existed since Ver.32.5.2 but everything works without any problems

pavog commented 3 years ago

Thanks for reporting this issue. Mh, this error occurs on every load (onEnable()) when the MySQLEngine checks for all tables. It executes the "CREATE TABLE IF NOT EXISTS" statements for each table on every startup (I may want to change this in the future) and it seems that it does not work with the exchange table.

@eyebrawl123 can you check if the exchange table exists in your database and if so: Can you check if the two constraints "fk_exchange_currencyfrom" and "fk_exchange_currencyto" exist?

eyebrawl123 commented 3 years ago

I didn't find "fk_exchange_currencyfrom" and "fk_exchange_currencyto" in any of the cc3 tables.

pavog commented 3 years ago

Thank you. Can you try to add them manually and let me know the error message (if you get one)?

eyebrawl123 commented 3 years ago

Hi, unfortunately I have no idea about databases and don't know how to do it. I neither know what nor where to copy anything. Sorry I would rather live with the message than break something because there are several thousand users in the database

pavog commented 3 years ago

Ok, thank you. Would you please contact me privately? github@paulvogel.me