MySQL数据库驱动5.x升级到8.x

2020-08-03 14:41
13026
31779

文章背景
项目开发近几年一直用MySQL5.6x和MySQL5.7x,我的开发驱动也一直用mysql-connector-java-5x系列,我误以为MySQL5.x只能用5.x的驱动,mysql-connector-java-8x是MySQL8x才能使用。知道最近我发现一些项目用的是MySQL8x,驱动仍然是5.x,我才认真的百度一番,发现是自己错了。驱动与MySQL版本对应关系如下图:

  1. MySQL5.6x、5.7x、8.x均建议使用8x的驱动,据说性能有不少提升呢,本人升级测试后发现确实有所提升。我选用的MySQL驱动为最新8.0.21版本,MySQL则为5.7x,后续会把MySQL版本也升级下。
  2. 驱动升级步骤
    升级过程很简单,把驱动版本更新为8.x即可,还有一些细节要注意。

    1. driverClassName升级:由com.mysql.jdbc.Driver 更换为 com.mysql.cj.jdbc.Driver,不升级也会兼容,不过官网都推荐升级,我也就升了。
    2. MySQL 8.x 以上版本不需要建立 SSL 连接的,需要显式关闭。即useSSL=false。
    3. MySQL 8.x 需要设置时区,serverTimezone=Asia/Shanghai,关于时区自行百度,不要乱填(UTC比北京时间早8小时哟)。
  3. 最后贴上我配置的链接
    jdbc.url=jdbc:mysql://localhost:3306/dbName?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
     

全部评论

2020-11-29 08:24:53.0
MySQL数据库驱动5.x升级到8.x xminoreqf http://www.gppe6wafg71r6g026tnq9099e1751j1rs.org/ [url=http://www.gppe6wafg71r6g026tnq9099e1751j1rs.org/]uxminoreqf[/url] <a href="http://www.gppe6wafg71r6g026tnq9099e1751j1rs.org/">axminoreqf</a>
2020-11-17 15:47:21.0
MySQL数据库驱动5.x升级到8.x vtmjhftxjj http://www.g92j030fv26spcz544n925n8kaid5jm3s.org/ <a href="http://www.g92j030fv26spcz544n925n8kaid5jm3s.org/">avtmjhftxjj</a> [url=http://www.g92j030fv26spcz544n925n8kaid5jm3s.org/]uvtmjhftxjj[/url]
2020-11-17 10:34:10.0
MySQL数据库驱动5.x升级到8.x mnmtlvl http://www.g403lr59dp3494q1g9op60qdw9g7r0xrs.org/ <a href="http://www.g403lr59dp3494q1g9op60qdw9g7r0xrs.org/">amnmtlvl</a> [url=http://www.g403lr59dp3494q1g9op60qdw9g7r0xrs.org/]umnmtlvl[/url]
2020-11-11 12:37:14.0
MySQL数据库驱动5.x升级到8.x [url=http://www.gep863z1m7gntn41ue3tg214050x47aws.org/]ubtchhxthgl[/url] btchhxthgl http://www.gep863z1m7gntn41ue3tg214050x47aws.org/ <a href="http://www.gep863z1m7gntn41ue3tg214050x47aws.org/">abtchhxthgl</a>
2020-11-09 11:01:40.0
MySQL数据库驱动5.x升级到8.x <a href="http://www.g5t5dxz9m6thos9m283r64e07m6dx810s.org/">alkzcirh</a> lkzcirh http://www.g5t5dxz9m6thos9m283r64e07m6dx810s.org/ [url=http://www.g5t5dxz9m6thos9m283r64e07m6dx810s.org/]ulkzcirh[/url]
2020-10-25 12:19:22.0
I'm a housewife <a href="http://www.ttr-codnor.co.uk/acheter-moduretic-en-ligne.html">para que serve moduretic 50 mg</a> First, we should discard the double standard that we&rsquo;ve long applied to Islam as compared to other religions.That means we should view Islam as an appropriate target for criticism and satire, as we do Christianity and Judaism
2020-10-25 12:19:21.0
Sorry, I'm busy at the moment <a href="http://asoupar.ir/?order-finasteride-online-uk">finasteride for hair loss side effects</a> Jason Chaffetz, R-Utah, John Conyers, D-Mich., and Peter Welch, D-Vt., with a Senate version from Sens
2020-10-25 12:19:21.0
Accountant supermarket manager <a href="http://www.ttr-codnor.co.uk/acheter-moduretic-en-ligne.html">moduretic prescription needed</a> &ldquo;I would look at all the food retailers and ask &ndash; is this retailer looking to drive footfall into their shop to maintain its vitality?&rdquo; he explains
2020-10-25 12:19:20.0
How many weeks' holiday a year are there? <a href="http://galopturk.com/?antabuse-alcohol-reaction-time">disulfiram reaction that occurs with metronidazole and alcohol</a> A serious point -- to improve voter turnout among the young, I feel, you need to start early
2020-10-25 12:19:20.0
My battery's about to run out <a href="http://www.ttr-codnor.co.uk/acheter-moduretic-en-ligne.html">bula moduretic 50</a> Accompanied by the mid-range 730, Nokia also launched a new wireless charging plate and screen0-sharing device called the HD-10 to allow Lumia users to project content on their phones to their TV screens.