ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 数据库切换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 修改JPA加上database-platform参数 jpa: open-in-view: false database-platform: org.hibernate.dialect.SQLServerDialect ~~~ #### 3.sqlserver下定时任务报错处理 ~~~ 报错信息org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: sql injection violation, syntax error: syntax error, not support option : UPDATE, pos 86, line 1, column 80, token UPDATE ~~~ 修改配置如下:将selectWithLockSQL: SELECT\* FROM {0}LOCKS UPDLOCK WHERE LOCK\_NAME = ?配置在jobStore下 ~~~ quartz: .....省略其他配置..... properties: org: quartz: jobStore: selectWithLockSQL: SELECT* FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ? ~~~ #### 3.sqlserver下启动后,如果控制台一直滚动如下图信息 ![](https://img.kancloud.cn/be/87/be873f33063df556245b47d3d248d469_1890x473.png) 可修改配置文件 ~~~ web-stat-filter: enabled:false ~~~ ![](https://img.kancloud.cn/0b/0f/0b0f8771b0bfa379ed63c403c11f2722_236x53.png) ### postgresql数据库 #### 1.添加postgresql驱动,修改pom.xml (根据不同版本的数据库引入对应版本的驱动,下载地址:[https://jdbc.postgresql.org/download.html](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 ~~~