SQLService.kt
// Start connection
Database.connect("jdbc:mysql://127.0.0.1:3306/rsmod", driver = "com.mysql.jdbc.Driver", user = "root", password = "")
// Create tables if not yet created
transaction { // This line errors
mutableListOf<Table>(PlayerModel, SkillModel, ItemContainerModel, ItemModel).forEach {
table -> if(!table.exists())
SchemaUtils.create(table)
}
}
构建.gradle
compile 'org.jetbrains.exposed:exposed:0.13.6'
compile "mysql:mysql-connector-java:5.1.46"
错误日志
java.lang.ExceptionInInitializerError: null
at gg.rsmod.plugins.service.sql.SQLService$initSerializer$1.invoke(SQLService.kt:68) ~[plugins-0.0.4.jar:?]
at gg.rsmod.plugins.service.sql.SQLService$initSerializer$1.invoke(SQLService.kt:24) ~[plugins-0.0.4.jar:?]
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction(ThreadLocalTransactionManager.kt:104) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:75) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:58) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction$default(ThreadLocalTransactionManager.kt:58) ~[exposed-0.13.6.jar:?]
at gg.rsmod.plugins.service.sql.SQLService.initSerializer(SQLService.kt:67) ~[plugins-0.0.4.jar:?]
at gg.rsmod.game.service.serializer.PlayerSerializerService.init(PlayerSerializerService.kt:24) ~[main/:?]
at gg.rsmod.game.model.World.loadServices$game(World.kt:586) ~[main/:?]
at gg.rsmod.game.Server.startGame(Server.kt:124) ~[main/:?]
at gg.rsmod.game.Launcher.main(Launcher.kt:11) ~[main/:?]
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_211]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_211]
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97) ~[kotlin-reflect-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Instance.call(CallerImpl.kt:113) ~[kotlin-reflect-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:106) ~[kotlin-reflect-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at kotlin.reflect.jvm.internal.KProperty1Impl.get(KProperty1Impl.kt:35) ~[kotlin-reflect-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at org.jetbrains.exposed.sql.Table.clone(Table.kt:212) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Table.cloneWithAutoInc(Table.kt:361) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Table.autoIncrement(Table.kt:365) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Table.autoIncrement$default(Table.kt:365) ~[exposed-0.13.6.jar:?]
at gg.rsmod.plugins.service.sql.model.PlayerModel.<clinit>(PlayerModel.kt:7) ~[plugins-0.0.4.jar:?]
... 11 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_211]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_211]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_211]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_211]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:342) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2188) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2221) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2016) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_211]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_211]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_211]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_211]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at java.sql.DriverManager.getConnection(DriverManager.java:664) ~[?:1.8.0_211]
at java.sql.DriverManager.getConnection(DriverManager.java:247) ~[?:1.8.0_211]
at org.jetbrains.exposed.sql.Database$Companion$connect$7.invoke(Database.kt:114) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$Companion$connect$7.invoke(Database.kt:72) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$Companion$doConnect$3.invoke(Database.kt:93) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$Companion$doConnect$3.invoke(Database.kt:72) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction$connectionLazy$1.invoke(ThreadLocalTransactionManager.kt:26) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction$connectionLazy$1.invoke(ThreadLocalTransactionManager.kt:23) ~[exposed-0.13.6.jar:?]
at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:81) ~[kotlin-stdlib-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction.getConnection(ThreadLocalTransactionManager.kt:32) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Transaction.getConnection(Transaction.kt) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database.getMetadata$exposed(Database.kt:18) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$url$2.invoke(Database.kt:27) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$url$2.invoke(Database.kt:16) ~[exposed-0.13.6.jar:?]
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) ~[kotlin-stdlib-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at org.jetbrains.exposed.sql.Database.getUrl(Database.kt) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$dialect$2.invoke(Database.kt:30) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$dialect$2.invoke(Database.kt:16) ~[exposed-0.13.6.jar:?]
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) ~[kotlin-stdlib-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at org.jetbrains.exposed.sql.Database.getDialect(Database.kt) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.vendors.DefaultKt.getCurrentDialect(Default.kt:365) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.vendors.DefaultKt.getCurrentDialectIfAvailable(Default.kt:369) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Column.getOnDelete$exposed(Column.kt:17) ~[exposed-0.13.6.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_211]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_211]
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97) ~[kotlin-reflect-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Instance.call(CallerImpl.kt:113) ~[kotlin-reflect-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:106) ~[kotlin-reflect-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at kotlin.reflect.jvm.internal.KProperty1Impl.get(KProperty1Impl.kt:35) ~[kotlin-reflect-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at org.jetbrains.exposed.sql.Table.clone(Table.kt:212) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Table.cloneWithAutoInc(Table.kt:361) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Table.autoIncrement(Table.kt:365) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Table.autoIncrement$default(Table.kt:365) ~[exposed-0.13.6.jar:?]
at gg.rsmod.plugins.service.sql.model.PlayerModel.<clinit>(PlayerModel.kt:7) ~[plugins-0.0.4.jar:?]
... 11 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method) ~[?:1.8.0_211]
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) ~[?:1.8.0_211]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:1.8.0_211]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:1.8.0_211]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:1.8.0_211]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[?:1.8.0_211]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:1.8.0_211]
at java.net.Socket.connect(Socket.java:589) ~[?:1.8.0_211]
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:301) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2188) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2221) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2016) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_211]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_211]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_211]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_211]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330) ~[mysql-connector-java-5.1.46.jar:5.1.46]
at java.sql.DriverManager.getConnection(DriverManager.java:664) ~[?:1.8.0_211]
at java.sql.DriverManager.getConnection(DriverManager.java:247) ~[?:1.8.0_211]
at org.jetbrains.exposed.sql.Database$Companion$connect$7.invoke(Database.kt:114) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$Companion$connect$7.invoke(Database.kt:72) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$Companion$doConnect$3.invoke(Database.kt:93) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$Companion$doConnect$3.invoke(Database.kt:72) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction$connectionLazy$1.invoke(ThreadLocalTransactionManager.kt:26) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction$connectionLazy$1.invoke(ThreadLocalTransactionManager.kt:23) ~[exposed-0.13.6.jar:?]
at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:81) ~[kotlin-stdlib-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction.getConnection(ThreadLocalTransactionManager.kt:32) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Transaction.getConnection(Transaction.kt) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database.getMetadata$exposed(Database.kt:18) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$url$2.invoke(Database.kt:27) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$url$2.invoke(Database.kt:16) ~[exposed-0.13.6.jar:?]
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) ~[kotlin-stdlib-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at org.jetbrains.exposed.sql.Database.getUrl(Database.kt) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$dialect$2.invoke(Database.kt:30) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Database$dialect$2.invoke(Database.kt:16) ~[exposed-0.13.6.jar:?]
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) ~[kotlin-stdlib-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at org.jetbrains.exposed.sql.Database.getDialect(Database.kt) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.vendors.DefaultKt.getCurrentDialect(Default.kt:365) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.vendors.DefaultKt.getCurrentDialectIfAvailable(Default.kt:369) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Column.getOnDelete$exposed(Column.kt:17) ~[exposed-0.13.6.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_211]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_211]
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97) ~[kotlin-reflect-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Instance.call(CallerImpl.kt:113) ~[kotlin-reflect-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:106) ~[kotlin-reflect-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at kotlin.reflect.jvm.internal.KProperty1Impl.get(KProperty1Impl.kt:35) ~[kotlin-reflect-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at org.jetbrains.exposed.sql.Table.clone(Table.kt:212) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Table.cloneWithAutoInc(Table.kt:361) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Table.autoIncrement(Table.kt:365) ~[exposed-0.13.6.jar:?]
at org.jetbrains.exposed.sql.Table.autoIncrement$default(Table.kt:365) ~[exposed-0.13.6.jar:?]
at gg.rsmod.plugins.service.sql.model.PlayerModel.<clinit>(PlayerModel.kt:7) ~[plugins-0.0.4.jar:?]
... 11 more
我已经尝试查看此类GitHub 问题并更改我的项目 SDK 以使用Koltin SDK 1.3.30
但没有更改。
我正在使用 JDK 8: 1.8 V1.8.0_211
。我可以通过浏览器上的 PHPMyAdmin 登录我的 SQL,这样我就知道我的 SQL 服务工作正常。
任何帮助,将不胜感激。