连接MySQL错误:create connection SQLException, url: jdbc:mysql://localhost:3306/*****?
具体报错如下:
2018-11-12 16:14:21.704 ERROR 9752 --- [eate-1537371824]
com.alibaba.druid.pool.DruidDataSource : create connection SQLException, url:
jdbc:mysql://localhost:3306/*****?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false,
errorCode 1193, state HY000
java.sql.SQLException: Unknown system variable 'query_cache_size'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3878)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3814)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2478)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2625)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2547)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2505)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1370)
at
com.mysql.jdbc.ConnectionImpl.loadServerVariables(ConnectionImpl.java:3862)
at
com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3290)
at
com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2299)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2085)
at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:795)
at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)
at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
at
com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:156)
at
com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:218)
at
com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:150)
at
com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1560)
at
com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1623)
at
com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2468)
解决方法:本人是MySQL版本问题,用的是MySQL8.0,将MySQL驱动改成如下:5.1.6
mysql
mysql-connector-java5.1.6
修改后的连接信息如下:
spring: datasource: type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver druid: first: #数据源1 url:
jdbc:mysql://localhost:3306/renren_fast?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
username: ***** password: ***** second: #数据源2 url:
jdbc:mysql://localhost:3306/renren_fast?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
username: ***** password: *****
........................