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

2020-08-03 14:41
10669
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-25 10:07:07.0
In a meeting <a href="http://yanaby.ir/hydrea-for-sickle-cell-anemia/">hydroxyurea in sickle cell disease ppt</a> Two sisters in northern Florida, aged 11 and 15, are behind bars and charged with murder for allegedly killing their older brother
2020-10-25 10:07:06.0
What's your number? <a href="http://yanaby.ir/hydrea-for-sickle-cell-anemia/">how i use hydroxyurea to treat young patients with sickle cell anemia</a> Sisi crushed the Muslim Brotherhood after removing them from power as army chief last year, but hardcore Islamist insurgents have defied security crackdowns and killed hundreds of security forces, damaging the country's vital tourist trade.
2020-10-25 10:07:06.0
I'm sorry, he's <a href="http://wilkinsplastering.co.uk/precose-mechanism-of-action.html">precose</a> 11 to get to the roof of an administration building at the prison entrance during an evening recreation period and then jumped 15 feet to the ground outside to escape through a soybean field, the report said.
2020-10-25 10:07:04.0
Hello good day <a href="http://wilkinsplastering.co.uk/norethindrone-generic-for-aygestin.html">buy aygestin online</a> During the 1940s Horst worked primarily in the Conde Nast studio on the 19th floor of the Graybar Building, an Art Deco skyscraper on Manhattan&#039;s Lexington Avenue.
2020-10-25 10:07:03.0
Are you a student? <a href="http://vaccineresource.com/clozapine-vs-clozaril/">clozapine max dose</a> at Washington's National Law Enforcement Officers Memorial and march to the Capitol, where speakers will address the crowd, said rally organizer Kelly Wince.
2020-10-25 09:45:18.0
How do you know each other? <a href="http://plantfoods.org/minipress-ptsd-dosage.html">minipress xl max dose</a> Sandoz is the world leader in cheaper copies of biotechmedicines known as biosimilars, which are expected to accountfor approximately one quarter of the $100 billion worth of salesstemming from off-patent biological drugs by the end of thedecade.
2020-10-25 09:45:18.0
How do I get an outside line? <a href="http://prepa-sarcelles.fr/betnovate-cream-uk-online.php">precio betnovate locion capilar</a> DAVOS, Switzerland - Countries must devote more resources to fight global extremism, U.S
2020-10-25 09:45:17.0
The United States <a href="http://fanatic.ir/levitra-20-mg-bez-recepta">comprare levitra originale online</a> And he wanted the media, at least the parts of it who thought this story was important and his message was important, to stand with him.
2020-10-25 09:45:16.0
How many are there in a book? <a href="http://drandrewbrown.co.uk/how-much-does-the-depo-provera-shot-cost-in-australia.html">provera reddit</a> But after months of hard negotiating, Apple offered a deal under which it would shift away economic risk by lending GT Advanced the money to build the furnaces and grow the sapphire, and then sell it exclusively to Apple for less than market value, Squiller wrote.
2020-10-25 09:45:12.0
When do you want me to start? <a href="http://www.coachhiredirect.co.uk/plant-amaryllis-bulbs-outside/">plant amaryllis bulbs outside</a> Peter's Square, a year after an attack by a seagull and a crow on the symbolic birds sparked protests by animal protection groups.