springboot連接不同數(shù)據(jù)庫的寫法詳解
MySQL
當url連接不指定/數(shù)據(jù)庫名
可以訪問到mysql服務器上有權限的任何庫,但是所有sql需要加上庫名前綴.
- pom
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency>
- 配置
spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://127.0.0.1:3306/text?ssl=false&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=true&allowMultiQueries=true username: username password: password
達夢
達夢新建用戶的時候會同時創(chuàng)建一個同名的數(shù)據(jù)庫并綁定,這時候這個用戶訪問同名數(shù)據(jù)庫的時候不需要加庫名前綴.
,否則所有sql都需要加上庫名前綴.
- pom
<dependency> <groupId>com.dameng</groupId> <artifactId>DmJdbcDriver18</artifactId> <version>8.1.1.193</version> </dependency>
- 配置
spring: datasource: driver-class-name: dm.jdbc.driver.DmDriver url: jdbc:dm://127.0.0.1:5236/TEST??ssl=false&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=true&allowMultiQueries=true username: username password: password
到此這篇關于springboot連接不同數(shù)據(jù)庫的寫法的文章就介紹到這了,更多相關springboot連接數(shù)據(jù)庫內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
- SpringBoot配置連接兩個或多個數(shù)據(jù)庫的實現(xiàn)
- 一文了解SpringBoot是如何連接數(shù)據(jù)庫的
- SpringBoot連接MySql數(shù)據(jù)庫的原理及代碼示例
- SpringBoot配置多個數(shù)據(jù)源超簡單步驟(連接多個數(shù)據(jù)庫)
- 詳解如何在SpringBoot中配置MySQL數(shù)據(jù)庫的連接數(shù)
- IDEA中SpringBoot項目數(shù)據(jù)庫連接加密方法
- springboot項目連接多種數(shù)據(jù)庫該如何操作詳析
- springboot連接多個數(shù)據(jù)庫的實現(xiàn)方法
相關文章
SpringBoot中的@EnableConfigurationProperties注解詳細解析
這篇文章主要介紹了SpringBoot中的@EnableConfigurationProperties注解詳細解析,如果一個配置類只配置@ConfigurationProperties注解,而沒有使用@Component或者實現(xiàn)了@Component的其他注解,那么在IOC容器中是獲取不到properties 配置文件轉(zhuǎn)化的bean,需要的朋友可以參考下2024-01-01Java網(wǎng)絡通信中ServerSocket的設計優(yōu)化方案
今天小編就為大家分享一篇關于Java網(wǎng)絡通信中ServerSocket的設計優(yōu)化方案,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-04-04Mybatis-plus 批量插入太慢的問題解決(提升插入性能)
公司使用的Mybatis-Plus操作SQL,用過Mybatis-Plus的小伙伴一定知道他有很多API提供給我們使用,但是批量插入大數(shù)據(jù)太慢應該怎么解決,本文就詳細的介紹一下,感興趣的可以了解一下2021-11-11SpringBoot中的RestTemplate使用方法詳解
這篇文章主要介紹了SpringBoot中的RestTemplate使用方法詳解,為了方便使用,這里我封裝成一個工具類來靜態(tài)調(diào)用RestTemplate,基于SpringBoot2.4.2版本,需要的朋友可以參考下2024-01-01