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

⚠ SQLibrary 7.1 no longer functions on newer Paper builds #3948

Open
Brickgard opened this issue May 6, 2021 · 5 comments
Open

⚠ SQLibrary 7.1 no longer functions on newer Paper builds #3948

Brickgard opened this issue May 6, 2021 · 5 comments
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. PR available Issues which have a yet-to-be merged PR resolving it priority: medium Issues that are detrimental to user experience (prohibitive bugs or lack of useful implementation). variables Related to variables and/or storing them.

Comments

@Brickgard
Copy link

Description

As of Paper build #587 some MySQL elements have changed, requiring some sort of class update for anything that uses MySQL.
Because of this, as of that build MySQL databases cannot be used by Skript.

Steps to Reproduce

Paper build #587+
Skript + SQLibrary 7.1 no longer connects to a MySQL Database
Reverting to Paper build #586 still operates fine.

Errors

[13:02:25 WARN]: [Skript][MySQL] MySQL DataSource class missing: com.mysql.jdbc.jdbc2.optional.MysqlDataSource.
[13:02:25 ERROR]: #!#!
[13:02:25 ERROR]: #!#! ===!!!=== Skript variable load error ===!!!===
[13:02:25 ERROR]: #!#! Unable to load (all) variables:
[13:02:25 ERROR]: #!#! Cannot connect to the database 'MySQL database'! Please make sure that all settings are correct and that the database software is running.
[13:02:25 ERROR]: #!#!
[13:02:25 ERROR]: #!#! Skript will work properly, but old variables might not be available at all and new ones may or may not be saved until Skript is able to create a backup of the old file and/or is able to connect to the database (which requires a restart of Skript)!
[13:02:25 ERROR]: #!#!

Server Information

Paper build Latest (or any build past #587)
Minecraft 1.16.5

Comments

I keep thinking there's a more "modern" solution to storing Skript variables in an SQL database, but my months of searching continually come up empty. If SQLibrary is depreciated, what replaced it?

@TheDGOfficial
Copy link
Contributor

Probably because they bumped mysql-connector-java from 5.x to 8.x to fix various security vulnerabilities. See PatPeter/SQLibrary#25 for a similar bump that's not merged. "If SQLibrary is deprecated, what replaced it?" nothing basically. There is some plugin probably providing similar hooks but Skript used SQLibrary for years, and the non-CSV databases in Skript right now are currently not in a good state too - most users use CSV so that's the most common and tested, stable configuration. I recommend not using SQL/MySQL with Skript until a revamp of the database system is made, or such.

For this specific issue though,
https://github.com/PatPeter/SQLibrary/blob/master/src/main/java/lib/PatPeter/SQLibrary/MySQL.java#L114 community can fork the project and change this line to use com.mysql.cj.jdbc.MysqlDataSource.

As it does not use the data source but only loads it (seen from here https://github.com/PatPeter/SQLibrary/blob/master/src/main/java/lib/PatPeter/SQLibrary/MySQL.java#L133 - it is commented out!) and uses traditional way of DriverManager, thankly no code changes needed there, and as it is a constant string, you can also do this from Jar String Editor. Here is a version I modified (not tested):

SQLibrary-7.1-jse-modified-cj-jdbc.zip
(.zip because GitHub does not support uploading .jar files and .rar is not so cross platform whereas .zip is supported on all major OS'es)

You can also do it yourself and you can also modify world guard error messages and such with this site, without recompiling, forking, using git, gradle, maven, etc. it is simple and you can replace any constant string without ever messing with bytecode or recompilation manually.
https://leonardosnt.github.io/jar-string-editor/

As on "what can be done on Paper's or Skript's side" - Paper can create a backwards compatibility class named com.mysql.jdbc.jdbc2.optional.MysqlDataSource and redirect it to jdbc3/4 generic packages which is com.mysql.cj.jdbc.MysqlDataSource in 8.x after rename and com.mysql.jdbc.MysqlDataSource in some versions.

Though that will only allow connecting, if the code is written with JDBC 5.x specific implementation details in mind other errors may occur. Plugins need updating probably. As for what can be done Skript side, the same, but Paper doing it will be better since if Skript does that that class would probably cause duplicate classes on all versions that has 5.x driver (i.e Spigot, older Paper builds, older Paper MC releases, etc.)

For the Paper PR causing this see PaperMC/Paper#5474 , scroll down a bit and you'll see all the linked issues that this PR did break. This why testing is important. Even if it is a good change, there should be prior deprecation warnings and such. Not an instant removal/upgrade to major versions of dependencies used by plugins.. Not a fan of that PR.

Maybe Skript can switch to https://github.com/aikar/db - developed by aikar, this plugin also break with that PR but someone made a PR to fix it and it merged quickly. So it is still developed at least and made by aikar.

@TPGamesNL TPGamesNL added the variables Related to variables and/or storing them. label May 9, 2021
@fednelpat
Copy link
Contributor

I remember some time ago there was a discussion about changing the database skript used from csv to something else, does anyone remember what it was?

@TPGamesNL
Copy link
Member

I remember some time ago there was a discussion about changing the database skript used from csv to something else, does anyone remember what it was?

See #1168

@playsenge
Copy link

Probably because they bumped mysql-connector-java from 5.x to 8.x to fix various security vulnerabilities. See PatPeter/SQLibrary#25 for a similar bump that's not merged. "If SQLibrary is deprecated, what replaced it?" nothing basically. There is some plugin probably providing similar hooks but Skript used SQLibrary for years, and the non-CSV databases in Skript right now are currently not in a good state too - most users use CSV so that's the most common and tested, stable configuration. I recommend not using SQL/MySQL with Skript until a revamp of the database system is made, or such.

For this specific issue though, https://github.com/PatPeter/SQLibrary/blob/master/src/main/java/lib/PatPeter/SQLibrary/MySQL.java#L114 community can fork the project and change this line to use com.mysql.cj.jdbc.MysqlDataSource.

As it does not use the data source but only loads it (seen from here https://github.com/PatPeter/SQLibrary/blob/master/src/main/java/lib/PatPeter/SQLibrary/MySQL.java#L133 - it is commented out!) and uses traditional way of DriverManager, thankly no code changes needed there, and as it is a constant string, you can also do this from Jar String Editor. Here is a version I modified (not tested):

SQLibrary-7.1-jse-modified-cj-jdbc.zip (.zip because GitHub does not support uploading .jar files and .rar is not so cross platform whereas .zip is supported on all major OS'es)

You can also do it yourself and you can also modify world guard error messages and such with this site, without recompiling, forking, using git, gradle, maven, etc. it is simple and you can replace any constant string without ever messing with bytecode or recompilation manually. https://leonardosnt.github.io/jar-string-editor/

As on "what can be done on Paper's or Skript's side" - Paper can create a backwards compatibility class named com.mysql.jdbc.jdbc2.optional.MysqlDataSource and redirect it to jdbc3/4 generic packages which is com.mysql.cj.jdbc.MysqlDataSource in 8.x after rename and com.mysql.jdbc.MysqlDataSource in some versions.

Though that will only allow connecting, if the code is written with JDBC 5.x specific implementation details in mind other errors may occur. Plugins need updating probably. As for what can be done Skript side, the same, but Paper doing it will be better since if Skript does that that class would probably cause duplicate classes on all versions that has 5.x driver (i.e Spigot, older Paper builds, older Paper MC releases, etc.)

For the Paper PR causing this see PaperMC/Paper#5474 , scroll down a bit and you'll see all the linked issues that this PR did break. This why testing is important. Even if it is a good change, there should be prior deprecation warnings and such. Not an instant removal/upgrade to major versions of dependencies used by plugins.. Not a fan of that PR.

Maybe Skript can switch to https://github.com/aikar/db - developed by aikar, this plugin also break with that PR but someone made a PR to fix it and it merged quickly. So it is still developed at least and made by aikar.

It worked! I love uuuu

@TheLimeGlass TheLimeGlass added the priority: medium Issues that are detrimental to user experience (prohibitive bugs or lack of useful implementation). label Mar 25, 2023
@TheLimeGlass TheLimeGlass pinned this issue Mar 25, 2023
@TheLimeGlass
Copy link
Contributor

TheLimeGlass commented Mar 25, 2023

Pinning so users can view this for possible solutions until Skript has a proper SQL system.

See the following for a modern experiment download to a Skript version to soon be implemented #5646

@AyhamAl-Ali AyhamAl-Ali changed the title SQLibrary 7.1 no longer functions on newer Paper builds ⚠ SQLibrary 7.1 no longer functions on newer Paper builds Apr 16, 2023
@TheLimeGlass TheLimeGlass added the PR available Issues which have a yet-to-be merged PR resolving it label Apr 26, 2023
@APickledWalrus APickledWalrus unpinned this issue Sep 30, 2023
@APickledWalrus APickledWalrus pinned this issue Sep 30, 2023
@Moderocky Moderocky unpinned this issue Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. PR available Issues which have a yet-to-be merged PR resolving it priority: medium Issues that are detrimental to user experience (prohibitive bugs or lack of useful implementation). variables Related to variables and/or storing them.
Projects
None yet
Development

No branches or pull requests

6 participants