Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eyebrawl123 opened this issue Apr 19, 2021 · 5 comments
Open

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

eyebrawl123 opened this issue Apr 19, 2021 · 5 comments
Assignees
Labels
Type: Bug Something isn't working

Comments

@eyebrawl123
Copy link

[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
Copy link
Owner

pavog commented Apr 19, 2021

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?

  • CONSTRAINT `cc3_fk_exchange_currencyfrom` FOREIGN KEY (from_currency) REFERENCES cc3_currency (name) ON UPDATE CASCADE ON DELETE CASCADE
  • CONSTRAINT `fk_exchange_currencyto` FOREIGN KEY (to_currency) REFERENCES cc3_currency (name) ON UPDATE CASCADE ON DELETE CASCADE

@pavog pavog self-assigned this Apr 19, 2021
@pavog pavog added the Type: Bug Something isn't working label Apr 19, 2021
@eyebrawl123
Copy link
Author

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

@pavog
Copy link
Owner

pavog commented Apr 19, 2021

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

@eyebrawl123
Copy link
Author

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
Copy link
Owner

pavog commented Apr 20, 2021

Ok, thank you. Would you please contact me privately? [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants