application.yml 或 application.properties 连接数据库配置

MySQL 配置

#yml

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/my_db(my_db为数据库名称)
    username: root
    password: root
#properties

spring.datasource.url=jdbc:mysql://域名:端口号/数据库名称?characterEncoding=UTF-8
spring.datasource.username=用户名
spring.datasource.password=密码
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.max-active=20
spring.datasource.max-idle=8
spring.datasource.min-idle=8
spring.datasource.initial-size=10

SqlServer 配置

#yml

spring:
  datasource:
    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test(test数据库名称)
    username: sa
    password: root

 

#properties

spring.datasource.master.jdbc-url=jdbc:sqlserver://127.0.0.1:1433;DatabaseName=land_db
spring.datasource.master.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.master.username=sa
spring.datasource.master.password=root

Oracle配置:

#properties

spring.datasource.url=jdbc:oracle:thin:@localhost:1521:data
spring.datasource.username=xxx
spring.datasource.password=xxx
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.max-idle=10
spring.datasource.max-wait=10000
spring.datasource.min-idle=5
spring.datasource.initial-size=5

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值