首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >o.a.tomcat.jdbc.pool.ConnectionPool :无法创建池的初始连接。Spring Boot + MySql

o.a.tomcat.jdbc.pool.ConnectionPool :无法创建池的初始连接。Spring Boot + MySql
EN

Stack Overflow用户
提问于 2018-05-14 04:11:47
回答 1查看 9.6K关注 0票数 0

我想在MySql WorkBranch的帮助下把Spring boot应用程序和数据库连接起来

代码语言:javascript
复制
o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.

是我得到的异常

pom.xml

代码语言:javascript
复制
<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.27</version>
        </dependency>

application.properties

代码语言:javascript
复制
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工作分支服务器是图像:https://i.stack.imgur.com/F3G4s.png

我知道这个错误

代码语言:javascript
复制
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和数据库连接起来吗?谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-14 06:59:23

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

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50320234

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档