mrzhqiang / ms079

冒险岛 v079 版本,源码来自网络,本仓库作为研究学习用途。
126 stars 82 forks source link

能连上服务器,但是控制台会输出一个错误java.sql.SQLException: Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY. #8

Closed jcc563768606 closed 3 years ago

jcc563768606 commented 3 years ago

游戏到了账号密码界面一直说创建成功,重新登陆,用admin/admin账号,点连接一直是这个提示

jcc563768606 commented 3 years ago

debug了一下看到是数据库查询账号的时候操作失败了 image

jcc563768606 commented 3 years ago

看起来是jdbc和mysql版本不搭配了,行吧,我把自己的mysql删掉换一个低版本的吧

mrzhqiang commented 3 years ago

Manifest-Version: 1.0 Ant-Version: Apache Ant 1.7.1 Created-By: 1.4.2-b28 (Sun Microsystems Inc.) Built-By: mysqldev Bundle-Vendor: Sun Microsystems Inc. Bundle-Classpath: . Bundle-Version: 5.1.12 Bundle-Name: Sun Microsystems' JDBC Driver for MySQL Bundle-ManifestVersion: 2 Bundle-SymbolicName: com.mysql.jdbc Export-Package: com.mysql.jdbc;version="5.1.12";uses:="com.mysql.jdbc. log,javax.naming,javax.net.ssl,javax.xml.transform,org.xml.sax",com.m ysql.jdbc.jdbc2.optional;version="5.1.12";uses:="com.mysql.jdbc,com.m ysql.jdbc.log,javax.naming,javax.sql,javax.transaction.xa",com.mysql. jdbc.log;version="5.1.12",com.mysql.jdbc.profiler;version="5.1.12";us es:="com.mysql.jdbc",com.mysql.jdbc.util;version="5.1.12";uses:="com. mysql.jdbc.log",com.mysql.jdbc.exceptions;version="5.1.12",com.mysql. jdbc.exceptions.jdbc4;version="5.1.12";uses:="com.mysql.jdbc",com.mys ql.jdbc.interceptors;version="5.1.12";uses:="com.mysql.jdbc",com.mysq l.jdbc.integration.c3p0;version="5.1.12",com.mysql.jdbc.integration.j boss;version="5.1.12",com.mysql.jdbc.configs;version="5.1.12",org.gjt .mm.mysql;version="5.1.12" Import-Package: javax.net,javax.net.ssl;version="[1.0.1, 2.0.0)";resol ution:=optional,javax.xml.parsers, javax.xml.stream,javax.xml.transfo rm,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transfor m.stax,javax.xml.transform.stream,org.w3c.dom,org.xml.sax,org.xml.sax .helpers;resolution:=optional,javax.naming,javax.naming.spi,javax.sql ,javax.transaction.xa;version="[1.0.1, 2.0.0)";resolution:=optional,o rg.apache.commons.logging;version="[1.1.1,2.0.0)";resolution:=optiona l,org.apache.log4j;version="[1.2.15, 2.0.0)";resolution:=optional,com .mchange.v2.c3p0;version="[0.9.1.2, 1.0.0)";resolution:=optional,org. jboss.resource.adapter.jdbc;resolution:=optional,org.jboss.resource.a dapter.jdbc.vendor;resolution:=optional

Name: common Specification-Title: JDBC Specification-Version: 4.0 Specification-Vendor: Sun Microsystems Inc. Implementation-Title: MySQL Connector/J Implementation-Version: 5.1.12 Implementation-Vendor-Id: com.mysql Implementation-Vendor: Sun Microsystems Inc.

mrzhqiang commented 3 years ago

原版本用的这个 JDBC

mrzhqiang commented 3 years ago

java.sql.SQLException: Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY

这个异常是不能向前操作数据集。

修复的方案是当遇到 rs.first 或 rs.last 方法时,替换为 isFirst 或 isLast

mrzhqiang commented 3 years ago

修复的方案是当遇到 rs.first 或 rs.last 方法时,替换为 isFirst 或 isLast 前面的方案不是最佳办法。

参考这篇文章: https://www.jianshu.com/p/05f643f27246

应该对 prepareStatement 相关方法进行修改,如下:

PreparedStatement ipc = con.prepareStatement("SELECT macs FROM accounts WHERE macs = ?", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

目前已根据此方案,对代码进行修复。

jcc563768606 commented 3 years ago

ERRORjava.sql.SQLDataException: Unsupported conversion from TIMESTAMP to java.lang.Long

mrzhqiang commented 3 years ago

触发异常的步骤是什么呢?

jcc563768606 commented 3 years ago

debug,服务器都能正常启动,到账号登录的时候就会因为这个error不能查询数据库

jcc563768606 commented 3 years ago

用的是5.7.35的mysql,后来我把mysql-connector-java的版本改小就可以用了5.1.*