Sfoglia il codice sorgente

金仓数据库,建表时候判断,sql语句适配金仓数据库

zhangchenglong 2 anni fa
parent
commit
88029edf9c

+ 12 - 12
pom.xml

@@ -10,8 +10,8 @@
     </parent>
     <groupId>com.syjy</groupId>
     <artifactId>calculation-spring-boot-starter</artifactId>
-    <version>0.0.4</version>
-    <!--<version>0.0.3-SNAPSHOT</version>-->
+    <version>0.0.5</version>
+    <!--<version>0.0.5-SNAPSHOT</version>-->
     <name>calculation</name>
     <description>Demo project for Spring Boot</description>
     <properties>
@@ -42,11 +42,11 @@
         </dependency>
 
         <!--本地使用时候放开-->
-        <dependency>
-            <groupId>kingbasejdbc4</groupId>
-            <artifactId>kingbasejdbc4</artifactId>
-            <version>1</version>
-        </dependency>
+        <!--<dependency>-->
+            <!--<groupId>kingbasejdbc4</groupId>-->
+            <!--<artifactId>kingbasejdbc4</artifactId>-->
+            <!--<version>1</version>-->
+        <!--</dependency>-->
 
         <!-- druid 连接池 -->
         <dependency>
@@ -108,11 +108,11 @@
         </dependency>
 
         <!--发布时候放开-->
-        <!--<dependency>-->
-            <!--<groupId>com.alibaba.cloud</groupId>-->
-            <!--<version>2.2.0.RELEASE</version>-->
-            <!--<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>-->
-        <!--</dependency>-->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <version>2.2.0.RELEASE</version>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
     </dependencies>
 
     <distributionManagement>

+ 12 - 5
src/main/java/com/syjy/calculate/repository/repositoryImpl/CalculationFormulaRepositoryImpl.java

@@ -40,6 +40,14 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
      */
     @Override
     public void initTable() {
+        log.info("初始化建表");
+        // 获取数据库类型
+        String dbType = properties.getDbType();
+        // 如果是金仓数据库,直接初始化表
+        if(CalculateResult.DB_KINGBASE.equals(dbType)){
+            this.createTable();
+            return;
+        }
 
         // 从配置文件中获取版本
         String version = properties.getVersion();
@@ -51,11 +59,8 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
             count = jdbcTemplate.queryForObject(checkSql, Integer.class);
         } catch (DataAccessException e) {
             // 如果表不存在,则创建表
-            if(CalculateResult.DB_ERROR_TABLE_EXIST.equals(e.getCause().toString()) || e.getCause().toString().indexOf("exist")>-1){
-                this.createTable();
-            }else{
-                e.printStackTrace();
-            }
+            log.error(e.toString());
+            this.createTable();
         }
 
         // 再次查询表中数据
@@ -347,6 +352,7 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
      */
     private void createTable() {
         try {
+            log.info("---------------开始创建准确率计算表---------------");
             // 从配置文件中获取版本
             String dbType = properties.getDbType();
             String path;
@@ -379,6 +385,7 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
         } catch (IOException e) {
             e.printStackTrace();
         }
+        log.info("---------------结束创建准确率计算表---------------");
         // 更新公式
         updateVersion();
     }

File diff suppressed because it is too large
+ 2 - 118
src/main/resources/sql/t_calculation_formula_king_base.sql


Some files were not shown because too many files changed in this diff