springboot連接不同數(shù)據(jù)庫(kù)的寫法詳解
MySQL
當(dāng)url連接不指定/數(shù)據(jù)庫(kù)名
可以訪問到mysql服務(wù)器上有權(quán)限的任何庫(kù),但是所有sql需要加上庫(kù)名前綴.
- 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
達(dá)夢(mèng)
達(dá)夢(mèng)新建用戶的時(shí)候會(huì)同時(shí)創(chuàng)建一個(gè)同名的數(shù)據(jù)庫(kù)并綁定,這時(shí)候這個(gè)用戶訪問同名數(shù)據(jù)庫(kù)的時(shí)候不需要加庫(kù)名前綴.
,否則所有sql都需要加上庫(kù)名前綴.
- 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
到此這篇關(guān)于springboot連接不同數(shù)據(jù)庫(kù)的寫法的文章就介紹到這了,更多相關(guān)springboot連接數(shù)據(jù)庫(kù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- SpringBoot配置連接兩個(gè)或多個(gè)數(shù)據(jù)庫(kù)的實(shí)現(xiàn)
- 一文了解SpringBoot是如何連接數(shù)據(jù)庫(kù)的
- SpringBoot連接MySql數(shù)據(jù)庫(kù)的原理及代碼示例
- SpringBoot配置多個(gè)數(shù)據(jù)源超簡(jiǎn)單步驟(連接多個(gè)數(shù)據(jù)庫(kù))
- 詳解如何在SpringBoot中配置MySQL數(shù)據(jù)庫(kù)的連接數(shù)
- IDEA中SpringBoot項(xiàng)目數(shù)據(jù)庫(kù)連接加密方法
- springboot項(xiàng)目連接多種數(shù)據(jù)庫(kù)該如何操作詳析
- springboot連接多個(gè)數(shù)據(jù)庫(kù)的實(shí)現(xiàn)方法
相關(guān)文章
SpringBoot中的@EnableConfigurationProperties注解詳細(xì)解析
這篇文章主要介紹了SpringBoot中的@EnableConfigurationProperties注解詳細(xì)解析,如果一個(gè)配置類只配置@ConfigurationProperties注解,而沒有使用@Component或者實(shí)現(xiàn)了@Component的其他注解,那么在IOC容器中是獲取不到properties 配置文件轉(zhuǎn)化的bean,需要的朋友可以參考下2024-01-01Java網(wǎng)絡(luò)通信中ServerSocket的設(shè)計(jì)優(yōu)化方案
今天小編就為大家分享一篇關(guān)于Java網(wǎng)絡(luò)通信中ServerSocket的設(shè)計(jì)優(yōu)化方案,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2019-04-04Mybatis-plus 批量插入太慢的問題解決(提升插入性能)
公司使用的Mybatis-Plus操作SQL,用過(guò)Mybatis-Plus的小伙伴一定知道他有很多API提供給我們使用,但是批量插入大數(shù)據(jù)太慢應(yīng)該怎么解決,本文就詳細(xì)的介紹一下,感興趣的可以了解一下2021-11-11簡(jiǎn)單易懂的Java Map數(shù)據(jù)添加指南
Java提供了多種方法來(lái)往Map中添加數(shù)據(jù),開發(fā)者可以根據(jù)具體需求選擇合適的方法,需要的朋友可以參考下2023-11-11SpringBoot中的RestTemplate使用方法詳解
這篇文章主要介紹了SpringBoot中的RestTemplate使用方法詳解,為了方便使用,這里我封裝成一個(gè)工具類來(lái)靜態(tài)調(diào)用RestTemplate,基于SpringBoot2.4.2版本,需要的朋友可以參考下2024-01-01