2

Completely unfamiliar with java/tomcat/mysql. So apologies... Setting up a third part application

Windows environment Tomcat is on the local machine and running. mysql is on the local machine and running. java is on the local machine and running.

This is the config.properties file

##############################   database config begin  ##############################
db.driverClassName=com.mysql.jdbc.Driver
db.url=jdbc:mysql://127.0.0.1:3306/hanshow_shopweb_v17n? 
autoReconnect=true&useUnicode=true&characterEncoding=UTF- 
8&zeroDateTimeBehavior=convertToNull&connectTimeout=30000
&socketTimeout=180000&allowMultiQueries=true&useSSL=false&useCompression=true
db.username=hanshow
db.password=9rztak
db.maxActive=20
db.maxIdle=20
db.maxWait=60000
db.defaultAutoCommit=true

I am getting an error with trying to connect to mysql. Think it must be something simple I am not sure what to do next.

In the tomcat logs I see

[ERROR] [Druid-ConnectionPool-Create-710941460] create connection error, url: jdbc:mysql://127.0.0.1:3306/hanshow_shopweb_v17n?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&connectTimeout=30000&socketTimeout=180000&allowMultiQueries=true&useSSL=false&useCompression=true, errorCode 0, state 08001
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

Any direction appreciated.

kobaltoloy
  • 149
  • 1
  • 12
doose11
  • 23
  • 3
  • Possible duplicate of [jdbc : Could not create connection to database server](https://stackoverflow.com/questions/41637604/jdbc-could-not-create-connection-to-database-server). – LHCHIN Nov 11 '19 at 02:41
  • Is your MySQL server running in the localhost of the application? on port 3306? – user207421 Nov 11 '19 at 05:34

1 Answers1

-1

Other reports and solutions of the same error seem to indicate a version mismatch between client and server (I know, a simple error message to that effect would be too much to ask of the mysql developers, right?) which can be solved by making sure that the client is up-to-date with respect to the server. The latest client should generally do it.

Java applications usually use the maven build system, which means that in your project there should be a file called pom.xml. Somewhere within that file there should be a <dependency> tag with a <groupid> tag of mysql and an <artifactId> tag of mysql-connector-java. There should also be a <version> tag. (If not, you will need to add it.) Make sure the <version> there is the latest possible.

You can find the latest version of the client by visiting this address: https://mvnrepository.com/artifact/mysql/mysql-connector-java

Once you have updated the client version, execute mvn install for maven to download the new version of the driver, and rebuild your project.

Mike Nakis
  • 56,297
  • 11
  • 110
  • 142
  • There is no requirement for the MySQL server version to match the MySQL Connector/J version. They don't even draw version numbers from the same space. If you use the latest version of the connector you should be able to communicate with all MySQL server versions. – user207421 Nov 11 '19 at 05:38
  • @user207421 but the fact remains that other reports and solutions of the same error seem to indicate precisely this: a version mismatch. The concept of backwards compatibility should mean that there should not be a version mismatch, but there seems to be one. What can we do? Anyway, I modified the answer to speak of updating the client to the latest version. – Mike Nakis Nov 11 '19 at 07:43