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就不会有任何问题了。

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。