MySQL版本与JDBC驱动的问题

我用eclipse写struts的注册页面的时候,出现了这个问题,我上网查了一下,有人说这个数据库表的引擎问题,我查看了引擎发现没有问题,还有人说是JDBC版本的问题,我就试着去更改我的JDBC的驱动版本,还真解决了问题,我出现的错误提示如下:

java.sql.SQLException:Could not retrieve transation read-only status server

atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)

atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)

atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)

atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)

atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:951)

atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:941)

atcom.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3939)

atcom.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3910)

atcom.mysql.jdbc.PreparedStatement.checkReadOnlySafeStatement(PreparedStatement.java:1258)

at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1278)

at com.dao.DbService.addUser(DbService.java:22)

at com.action.RegisterAction.execute(RegisterAction.java:94)

atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:601)

atcom.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)

atcom.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)

atcom.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)

atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atcom.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)

atorg.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)

atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atcom.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)

atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atcom.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)

atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atcom.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atorg.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atorg.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atcom.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atcom.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atorg.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atcom.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)

atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atcom.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atorg.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atcom.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

atcom.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)

atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)

atorg.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)

atorg.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)

at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)

atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)

atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)

atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)

atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)

atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)

atorg.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)

atorg.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)

atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at java.lang.Thread.run(Thread.java:722)

Caused by:
java.sql.SQLException: Unknown system variable ‘tx_read_only‘

atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2812)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2761)

atcom.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1612)

atcom.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3933)

... 74 more

我查看了我使用的JDBC版本是:mysql-connector-java-5.1.26-bin.jar;然后我查看了我的数据库版本是:

然后我把我的JDBC驱动版本换成:mysql-connector-java-5.1.5-bin.jar就不会有任何问题了。

时间: 2024-10-09 20:13:06

MySQL版本与JDBC驱动的问题的相关文章

IntelliJ IDEA+Mysql connecter/j JDBC驱动连接

在IntelliJ IDEA中用connecter/j jdbc驱动连接MYSQL 以下是解决过程,待整合...有点懒,有空再改 官方文档:https://www.cnblogs.com/cn-chy-com/p/10145690.html 创建了mysql新用户:https://blog.csdn.net/weixin_38091140/article/details/82983229 配置了JDK:https://blog.csdn.net/Elenal/article/details/53

mysql的版本对应jdbc驱动的版本

Connector/J 5.1 支持Mysql 4.1.Mysql 5.0.Mysql 5.1.Mysql 6.0 alpha这些版本.    Connector/J 5.0 支持MySQL 4.1.MySQL 5.0 servers.distributed transaction (XA).    Connector/J 3.1 支持MySQL 4.1.MySQL 5.0 servers.MySQL 5.0 except distributed transaction (XA) support

[Java] Oracle的JDBC驱动的版本说明

classes12.jar,ojdbc14.jar,ojdbc5.jar和ojdbc6.jar的区别,之间的差异 作者:赵磊 博客:http://elf8848.iteye.com 来源:http://elf8848.iteye.com/blog/811037 在使用Oracle JDBC驱动时,有些问题你是不是通过替换不同版本的Oracle  JDBC驱动来解决的?最常使用的ojdbc14.jar有多个版本,classes12.jar有多个版本你了解吗? 连接类型: 1.JDBC OCI: o

RCA:JDBC驱动自身问题引发的FullGC

郑昀 基于田志全和端木洪涛的分析报告 2015/6/30 关键词:Java,JDBC,升级,MySQL驱动,频繁数据查询,mysql-5.1.34,mysql-5.0.7 问题现象: 2015年4月22日(周日)晚间,线上 TaskMall 工程(一个 Java 工程)频繁报警.分析 jvm 情况,taskmall 在内存使用上确实存在问题,可能有大量对象不正常堆积: 图2 155 jmap 问题原因: 频繁的大数据查询场景下,mysql-5.1.34 驱动的性能远优于 mysql-5.0.7

MySQL的JDBC驱动(8.0版本)

1.引用外部库  mysql-connector-java-8.0.版本的jar 2.jdbc驱动类:com.mysql.jdbc.Driver  改成 com.mysql.cj.jdbc.Driver 3.jdbcUrl:jdbc:mysql://{ip}:{port}/{db}?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true 原文地址:https://www

MySQL 读写分离 使用驱动com.mysql.jdbc.ReplicationDriver

说明文档:http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-replication-connection.html 代码例子: 1 import java.sql.Connection; 2 import java.sql.ResultSet; 3 import java.util.Properties; 4 5 import com.mysql.jdbc.ReplicationDriver; 6 7 public clas

各种数据库(oracle、mysql、sqlserver等)在Spring中数据源的配置和JDBC驱动包

在开发基于数据库的应用系统时.须要在项目中进行数据源的配置来为数据 库的操作取得数据库连接. 配置不同数据库的数据源的方法大体上都是同样的.不同的仅仅是不同数据库的JDBC驱动类和连接URL以及对应的数据库username和密 码不同.以下列出8中经常使用的数据库的数据库数据源配置和对应的JDBC驱动包. 1.Spring中数据源配置格式 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSour

VBA连接MySQL数据库以及ODBC的配置(ODBC版本和MySQL版本如果不匹配会出现驱动和应用程序的错误)

db_connected = False '获取数据库连接设置dsn_name = Trim(Worksheets("加载策略").Cells(2, 5).Value)  ------(ODBC配置中的DATA SOURCE NAME)user_name = Trim(Worksheets("加载策略").Cells(3, 5).Value)pass_word = Trim(Worksheets("加载策略").Cells(4, 5).Value

maven添加sqlserver的jdbc驱动包

http://search.maven.org/中没有sqlserver的jdbc驱动,所以需要本地安装sqljdbc的jar包,然后再在pom里面引入 Step 1 在微软官网下载sqljdbc的jar包:http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774 本次下载了4.0版本 空间下载连接分享:https://yunpan.cn/cv3TjJqDZM7zu  访问密码 d6bb Step 2