register JDBC driver to work around Forge bug
This commit is contained in:
parent
033c2b8348
commit
ce0e173a9e
|
|
@ -151,7 +151,9 @@ dependencies {
|
||||||
// modImplementation project(":myproject")
|
// modImplementation project(":myproject")
|
||||||
|
|
||||||
// embedd the JDBC driver in the mod using jarJar
|
// embedd the JDBC driver in the mod using jarJar
|
||||||
runtimeOnly "com.mysql:mysql-connector-j:${jdbc_version}"
|
// JDBC driver auto-detection is broken in Forge as of v47.4.0
|
||||||
|
// i.e. we need to need it both at compile and runtime
|
||||||
|
implementation "com.mysql:mysql-connector-j:${jdbc_version}"
|
||||||
jarJar "com.mysql:mysql-connector-j:${jdbc_version}"
|
jarJar "com.mysql:mysql-connector-j:${jdbc_version}"
|
||||||
additionalRuntimeClasspath "com.mysql:mysql-connector-j:${jdbc_version}"
|
additionalRuntimeClasspath "com.mysql:mysql-connector-j:${jdbc_version}"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,11 @@ import vip.fubuki.playersync.sync.VanillaSync;
|
||||||
import vip.fubuki.playersync.util.JDBCsetUp;
|
import vip.fubuki.playersync.util.JDBCsetUp;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
import com.mysql.cj.jdbc.Driver;
|
||||||
|
|
||||||
@Mod(PlayerSync.MODID)
|
@Mod(PlayerSync.MODID)
|
||||||
public class PlayerSync {
|
public class PlayerSync {
|
||||||
|
|
@ -34,6 +36,14 @@ public class PlayerSync {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void commonSetup(final FMLCommonSetupEvent event) {
|
private void commonSetup(final FMLCommonSetupEvent event) {
|
||||||
|
// JDBC driver auto-detection is broken in Forge as of v47.4.0
|
||||||
|
// We need to register the driver manually
|
||||||
|
try {
|
||||||
|
DriverManager.registerDriver(new Driver());
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error("Unable to register JDBC MySQL driver", e);
|
||||||
|
}
|
||||||
|
|
||||||
VanillaSync.register();
|
VanillaSync.register();
|
||||||
if (JdbcConfig.SYNC_CHAT.get()) {
|
if (JdbcConfig.SYNC_CHAT.get()) {
|
||||||
ChatSync.register();
|
ChatSync.register();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user