数据库切换Oracle/SqlServer/Postgresql === ### Oracle数据 #### 1.添加oracle驱动,修改pom.xml ``` <!-- oracle驱动 --> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>11.2.0.3</version> </dependency> ``` #### 2.修改数据库连接 ``` 修改druid配置 validationQuery: SELECT 1 FROM DUAL driver-class-name: oracle.jdbc.OracleDriver url: jdbc:oracle:thin:@192.168.1.200:1521:ORCL username: jeecgboot password: jeecgboot ``` ### SQL server数据 #### 1.添加SQL server驱动,修改pom.xml ``` <!-- sqlserver--> <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>sqljdbc4</artifactId> <version>4.0</version> <scope>runtime</scope> </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 ```