gpt4 book ai didi

java - o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool. Spring Boot + MySql

转载 作者:行者123 更新时间:2023-11-29 17:35:18 25 4
gpt4 key购买 nike

我想在 MySql WorkBranch 的帮助下将 Spring boot 应用程序与数据库连接

o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.

是我得到的异常(exception)

pom.xml

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

应用程序属性

spring.thymeleaf.mode=LEGACYHTML5
#toa gore mora
# ===============================
# = DATA SOURCE
# ===============================

# Set here configurations for the database connection

# Connection url for the database "netgloo_blog"
spring.datasource.url = jdbc:mysql://localhost:3306/OnlineBanking

# Username and secret
spring.datasource.username = root
spring.datasource.password =

# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.tomcat.max-active=1

# ===============================
# = JPA / HIBERNATE
# ===============================

# Use spring.jpa.properties.* for Hibernate native properties (the prefix is
# stripped before adding them to the entity manager).

# Show or not log for each sql query
spring.jpa.show-sql = true

# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
spring.jpa.hibernate.ddl-auto = update

# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

在MySql Workbranch服务器中设置的图像是:/image/F3G4s.png

我收到这个错误

2018-05-13 22:04:38.234 ERROR 6176 --- [           main] o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_162]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_162]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_162]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_162]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[mysql-connector-java-5.1.27.jar:na]

有人可以帮忙连接 spring boot 和数据库吗谢谢

最佳答案

假设您处于开发环境中并且安全性对您来说不是问题,您可以使用以下 SQL 命令创建登录

CREATE USER 'jeffrey'@'*' IDENTIFIED BY 'password';
GRANT ALL ON * TO 'jeffrey'@'*';

另请参阅

https://dev.mysql.com/doc/refman/8.0/en/create-user.htmlhttps://dev.mysql.com/doc/refman/8.0/en/grant.html

关于java - o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool. Spring Boot + MySql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50320234/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com