亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Spring 連接到數據庫的問題

使用 Spring 連接到數據庫的問題

呼啦一陣風 2023-02-16 16:38:21
我正在使用帶有 Spring MVC 框架的簡單 mySQL 數據庫設置一個 CRUD 應用程序,但我在連接到數據庫時遇到問題。我收到以下錯誤:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure最后一個數據包成功發送到服務器。驅動程序尚未從服務器收到任何數據包。這是 DAO 的代碼:package com.ApplicationDevis.demo;import java.util.List;import org.springframework.data.jpa.repository.JpaRepository;import org.springframework.data.repository.CrudRepository;import org.springframework.stereotype.Repository;@Repositorypublic interface ProjetDAO extends JpaRepository<Utilisateur, Integer> // entité à gerer et le type de l'ID {}對于實體:@Entity public class Utilisateur{            @Id // pour dire que notre id et la cle primère    @GeneratedValue // pour dire qu'elle est auto incrémenté     int id;    String Nom;    String Prenom;    String Societe;    String Ville;    String CP;    String Num_Tel;    String email;對于我的application.properties:spring.datasource.url=jdbc:mysql://localhost:8080/BDD_Vanerum_Testspring.datasource.username=rootspring.datasource.password=ridaspring.jpa.show-sql=true and finaly my pom.xml :    <dependencies>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-data-jpa</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-thymeleaf</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-web</artifactId>        </dependency>        <dependency>            <groupId>mysql</groupId>            <artifactId>mysql-connector-java</artifactId>            <scope>runtime</scope>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-test</artifactId>            <scope>test</scope>        </dependency>    </dependencies>
查看完整描述

1 回答

?
呼如林

TA貢獻1798條經驗 獲得超3個贊

實際上這只是一個JAVA版本問題,我使用以下方法修復了它:

jdbc:mysql://localhost/BDD_Vanerum_Test?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

而不是我在前面的代碼中使用的行。


查看完整回答
反對 回復 2023-02-16
  • 1 回答
  • 0 關注
  • 134 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號