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

2020-08-03 14:41
10671
31774

文章背景
项目开发近几年一直用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-10-14 11:26:49.0
How many weeks' holiday a year are there? <a href="https://empirefitclub.com/what-do-cetirizine-tablets-look-like-qevp">cetirizine dihcl obat apa</a> "Buddhists accept their destiny and blame their predicament on the bad deeds they did in their previous lives," said Hu Jia, an AIDS activist and Buddhist who has been intermittently under house arrest since his release in 2011 after serving 42 months in prison for subversion.
2020-10-14 11:26:49.0
real beauty page <a href="http://itgamut.com/goodrx-gabapentin-341b">gabapentin 300 prospect</a> "Hollywood has a way of glamorizing everything up to andincluding vampires. This is a movie that highlights a part ofthe Internet that has real downside unless governments act,"said MGM spokesman Alan Feldman.
2020-10-14 11:26:49.0
Photography <a href="https://www.bardellrealestate.com/prolasta-hm2m">prolasta </a> Sierra Riddle learned a year ago that her son Landon, 3, had an aggressive form of leukemia. Doctors in their hometown of Salt Lake City began the standard treatment of radiation and chemotherapy, which took a heavy toll on his little body.
2020-10-14 11:26:48.0
I work with computers <a href="http://chrusher.com/ix/o2-store-artane-uzzz">lloyds pharmacy artane castle phone number</a> My 11-year-old son made a comment that I thought was rather astute. “Pop, this truck feels a lot smaller than it looks on the outside.” How true. The handling is much lighter than one would assume and the briskness of the acceleration makes it very easy to place in traffic and the ability to see each corner of the vehicle from the front inspires confidence. Not bad for 11.
2020-10-14 11:26:48.0
How do you do? <a href="https://avatasvir.com/clindamycin-gel-dosage-q32s">can clindamycin treat acne scars</a> In announcing its preliminary second-quarter earnings, UBS said it had "reached an agreement in principle" with the FHFA to settle claims related to the sale from 2004 to 2007 of securites backed by home mortgages.
2020-10-14 11:26:47.0
When can you start? <a href="https://isapointdecroix.fr/zithromax-getting-pregnant-s6c3">harga zithromax syrup</a> Acerola possesses the highest content of vitamin C of any plant-derived fruits or berries. One hundred grams of fresh berry provides an astounding 1677.6 milligrams of vitamin C, about 1,864 percent of daily recommended intake.
2020-10-14 11:26:24.0
Did you go to university? <a href="http://badshahifurniture.com/tribex-500-tablet-xwrc">tribex bolu</a> The headlines might be reserved for the increasingly haunted-looking David Moyes, but who in the Premier League has a harder job right now than Chris Hughton, with just four wins in his last 21 league matches? Mark Hughes is having an easier time &ndash; at 14th in the table, Stoke are three places above their opponents today &ndash; but then again, this is a guy who has taken on the task of turning Stoke City into a team of technical ball-players.
2020-10-14 11:26:24.0
What's the current interest rate for personal loans? <a href="http://www.concordiafutsal.com.br/web/vasotec-length-of-action-1s1z">buy vasotec</a> For the 2014 Cup, I will be one of four &ldquo;mobile&rdquo; marshals assigned to each player. Our role will be to stick with that player and his caddy throughout the whole match. Although I&rsquo;ve done marshalling before, it is a new idea to work like this and I think it sounds really interesting. We will be responsible for making sure the player can get around the Gleneagles site easily, as well as through the crowds on the course. It should make it easier for the player, because he will get to know us a little, and we will understand his needs and preferences better. There will be some ball spotting too, and we will have to make sure there is enough space to play shots unhindered if the player strays into the rough. In preparation I have done a couple of events up at Gleneagles this year so I know the course and the set up already and next season, in the run up to the Cup, I shall be marshalling at the BMW Championship at Wentworth and the British Seniors&rsquo; Open at Royal Porthcawl. I will also be going up to Scotland a couple of days before the players arrive for the final briefings. Who would I most like to be assigned to during the match? Without a doubt, Phil Mickelson. He may be one of the opposition, but he is an amazing player.
2020-10-14 11:26:23.0
Could I have a statement, please? <a href="http://bmf.com.vn/viagra-dapoxetine-online-purchase-pjz5">sildenafil citrate and dapoxetine tablets</a> The FA raised Poland's allocation to 18,000 to allay fears that away fans could infiltrate the home end but Hodgson accepts this could encourage England's opponents to achieve a result which would deny his team a place in next year's World Cup.
2020-10-14 11:26:21.0
I'm in my first year at university <a href="http://coachonlineoutlet-inc.com/cheap-generic-viagra-worcester-imc-y8qt">le viagra effets secondaires</a> New fossil-fuel plants to provide a back-up to the windfarms have not been built because operators are uncertain aboutwhether they will be able to recover construction costs in therelatively small number of hours that they are expected to runeach year.