数据库切换Oracle/SqlServer/Postgresql

Oracle数据

1.添加oracle驱动,修改pom.xml

  1. <!-- oracle驱动 -->
  2. <dependency>
  3. <groupId>com.oracle</groupId>
  4. <artifactId>ojdbc6</artifactId>
  5. <version>11.2.0.3</version>
  6. </dependency>

2.修改数据库连接

  1. 修改druid配置
  2. validationQuery: SELECT 1 FROM DUAL
  3. driver-class-name: oracle.jdbc.OracleDriver
  4. url: jdbc:oracle:thin:@192.168.1.200:1521:ORCL
  5. username: jeecgboot
  6. password: jeecgboot

SQL server数据

1.添加SQL server驱动,修改pom.xml

  1. <!-- sqlserver-->
  2. <dependency>
  3. <groupId>com.microsoft.sqlserver</groupId>
  4. <artifactId>sqljdbc4</artifactId>
  5. <version>4.0</version>
  6. <scope>runtime</scope>
  7. </dependency>

2.修改数据库连接

修改druid配置
validationQuery: SELECT 1
filters: stat,slf4j


driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://192.168.1.200:1433;SelectMethod=cursor;DatabaseName=jeecg-boot
username: sa
password: SA

postgresql数据库

1.添加postgresql驱动,修改pom.xml

(根据不同版本的数据库引入对应版本的驱动,下载地址:https://jdbc.postgresql.org/download.html)

<!--  postgresql-->
<dependency>
          <groupId>postgresql</groupId>
          <artifactId>postgresql</artifactId>
          <version>42.2.5</version>
        </dependency>

2.修改数据库连接

增加spring下的配置
spring:
  #postgresql 报错问题
  jpa:
      properties:
          hibernate:
              temp:
                  use_jdbc_metadata_defaults: false

修改druid配置
validationQuery: SELECT 1


url: jdbc:postgresql://localhost:5432/postgres
username: postgres
password: root
driver-class-name: org.postgresql.Driver