gpt4 book ai didi

java - 获取JDBC连接失败;嵌套异常是 java.sql.SQLException : null

转载 作者:行者123 更新时间:2023-12-01 17:50:40 25 4
gpt4 key购买 nike

从本地计算机中的数据库服务器获取以下响应,

{
"timestamp": "2020-03-22T13:18:30.383+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: null, message from server: \"Host '192.168.64.1' is not allowed to connect to this MariaDB server\"",
"path": "/users"
}

我的 Spring boot application.properties

# MySQL
spring.datasource.url=jdbc:mysql://192.168.64.2:3306/ctracker
spring.datasource.username=admin
spring.datasource.password=admin

logging.level.org.springframework=info
logging.level.org.springframework.jdbc=DEBUG

Phpmy管理控制台:

enter image description here

如何解决此问题?

Spring 启动堆栈跟踪,

java.sql.SQLException: null,  message from server: "Host '192.168.64.1' is not allowed to connect to this MariaDB server"
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473) [HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554) [HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) [HikariCP-3.4.2.jar:na]

最佳答案

我通过adding解决了这个问题phpmyadmin 中的新用户,

  1. Login to phpMyADmin.
  2. Go to Privileges.
  3. Click Add a new User.
  4. Type the access info you want in the Login Information area (username, host, password)
  5. Click on the radio button for Create database with same name and grant all privileges.
  6. Click Go.

关于java - 获取JDBC连接失败;嵌套异常是 java.sql.SQLException : null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60799867/

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