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

2020-08-03 14:41
10668
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:53.0
I'm not sure <a href="http://coachonlineoutlet-inc.com/d-aspartic-acid-d-aa-3qik">d-aspartic acid supplements side effects</a> Haque was born the youngest of three sisters in Portsmouth and, following her parents' divorce, lived with her British schoolteacher mother, Thelma. She took classes at the city's Rainbow School of Dance from the age of two and a half and attended the Priory School before moving to London to live with her Bangladeshi restaurateur father, Amirul, and train at the Arts Educational Schools.
2020-10-14 11:26:52.0
Could you tell me my balance, please? <a href="https://noithatanhphat.com.vn/geodon-reviews-bipolar-disorder-0dfq">how do you get off of geodon</a> Forecasting firm Macroeconomic Advisers cut its projection for second quarter GDP growth by two-tenths of a percentage point to a 0.5 percent annual rate on the weak shipments number. JPMorgan also lowered its forecast to 0.5 percent.
2020-10-14 11:26:52.0
I'd like to open a business account <a href="https://yuvatrip.com/what-is-the-brand-name-of-telmisartanhydrochlorothiazide-n4fm">cozaar plus hydrochlorothiazide</a> As a nation, the Americans may be searching for some answers. Sure, the United States won an impressive 25 medals. But only six of them were gold as Russia edged them with seven, making it the first time the U.S. failed to at least tie for the gold-medal lead since the first world championships in Helsinki 30 years ago.
2020-10-14 11:26:52.0
Withdraw cash <a href="https://www.bardellrealestate.com/losartan-hctz-100-25-mg-tab-side-effects-x9xo">losartan potasico 50 mg para q sirve</a> At the midday trading break, the CSI300 index ofthe leading Shanghai and Shenzhen A-share listings was up 0.9percent, while the Shanghai Composite Index rose 0.8percent. If gains hold, this will be their second-straight dailygain after closing last Tuesday at their lowest in six sessions.
2020-10-14 11:26:52.0
Children with disabilities <a href="http://www.ziontuition.com/dostinex-05-mg-price-in-saudi-arabia-vi4o">dostinex tablet 0.5 mg 8 tablet</a> Japan is one of the United States' most important trading and military partners and accustomed since the end of World War II to having renowned American political leaders serve as envoy. Former U.S. ambassadors to Japan include former Vice President Walter Mondale, former House Speaker Tom Foley and former Senate Majority Leaders Mike Mansfield and Howard Baker.
2020-10-14 11:26:51.0
I've been made redundant <a href="http://www.truenaturebliss.com/index.php/wellbutrin-75-mg-sr-tsqd">is generic wellbutrin being taken off the market</a> “I just don’t think it’s right for the neighborhood,” said City Councilman Jimmy Van Bramer (D-Sunnyside). “You can’t plop a big, shiny house in the middle of a landmarked neighborhood against the community’s wishes.”
2020-10-14 11:26:51.0
I was born in Australia but grew up in England <a href="https://www.bardellrealestate.com/medrol-4mg-dosepak-side-effects-ac69">medrol dose pack high blood sugar</a> Indeed, those industrious gits at EA Sports, whose latest FIFA incarnation is released today, have made football games not only true to life, but even better than the real thing. Swapping the uninspiring 0-0 showdowns of the Premier League for fully interactive goal feasts with near photo-realistic graphics, it&rsquo;s no wonder today&rsquo;s kids choose the comfy bosom of the living room over the dry mud of the football field. Besides, outdoors you could twist your ankle, get struck in the groin by the ball or accidentally swallow a wasp. At home, your worst fate is merely the shame of losing 10-0 in an online contest with a pubescent gamer from Guadalajara. That and a possible Vitamin D deficiency.
2020-10-14 11:26:51.0
It's a bad line <a href="https://guiadeluta.com.br/medexpresscom-r500">safet medex schnittschutz</a> In June, sales of German cars accounted for 26 percent of total sales in China, followed by Chinese vehicles at 25 percent, Japanese with 18 percent and U.S. cars with 16 percent, according to CAAM data.
2020-10-14 11:26:50.0
I was born in Australia but grew up in England <a href="https://happylights.pk/cialis-originale-miglior-prezzo-9lai">acheter cialis en pharmacie belgique</a> The four patients affected, who are in the NHS Lothian area, are aged between 62 and 84. The two who are seriously ill attended hospital but have been discharged. Symptoms include headache, diarrhoea and a dry cough followed by pneumonia.
2020-10-14 11:26:50.0
Directory enquiries <a href="http://www.randomclocks.com/index.php/ciproxin-200-mg-fiale-3it1">ciprofloxacino 250 mg ultrafarma</a> There have been calls for an inquiry into the standards of care in the NHS in Wales, particular after it was 12 people have died over the last 15 months while waiting for cardiac surgery at the University Hospital of Wales in Cardiff.