0

I can connect to my database from client , but could not connect from application, (mysql server is working). I can not get connection from datasource with this properties.

Problem:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
...
Caused by: java.lang.NullPointerException
at com.mysql.jdbc.ConnectionImpl.getServerCharacterEncoding(ConnectionImpl.java:3276)
at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1940)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1866)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1252)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2483)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2516)

mysql connector:

  <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.25</version>
    </dependency>

version mysql: 8.0.13

My properties for connection:

#DB properties:
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/sport_club4
db.username=root
db.password=12345
#Hibernate Configuration:
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect

hibernate.show_sql=true
entitymanager.packages.to.scan=com.netcracker.devschool.dev4.etalon.entity
4
  • try adding ?serverTimezone=UTC at the end of the connection string
    – vc73
    Nov 27, 2018 at 11:19
  • This is possibly a duplicate of stackoverflow.com/questions/50177907/… , the driver version you use is not compatible with your mysql version, try use the 5.1.46 or later
    – NickAth
    Nov 27, 2018 at 11:32
  • jdbc:mysql://localhost:3306/sport_club4?serverTimezone=UTC didnt help
    – flagmen
    Nov 27, 2018 at 11:33
  • thanks, update version help
    – flagmen
    Nov 27, 2018 at 11:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.