蓄电池监控管理平台数据库初始化程序
Administrator
2022-07-13 abffbf4d0cbda3dea8128f6c2c323a51a29f6dfa
BattMonitor_DB_Builder/src/com/sql/Sql_Mysql.java
@@ -35,6 +35,7 @@
   
   final public static String DB_DEV_HISTORY = "`db_dev_history`";                        //设备历史实时数据库
   
   final public static String DB_DEV_TESTPARAM = "`db_dev_testparam`";                        //设备历史实时数据库
   //--------------------------------------------------------------------------------------------//
   public final static String TB_HardDevSmsState = "tb_hard_dev_sms_state";
   //--------------------------------------------------------------------------------------------//
@@ -315,6 +316,9 @@
   /***************************** db_fbo_testdata 数据库  ************************************/
   public final static String Fbotestdata_Inf_Table = DB_FBO_TESTDATA + ".`tb_fbotestdata_inf`";
   
   /***************************** db_dev_testparam 数据库  **********************************/
   public final static String Batt_TestParam_Table = DB_DEV_TESTPARAM + ".tb_batt_testparam_";            //设备放电参数记录表
   
      
   //--------------------------------------------------------------------------------------------//
@@ -1157,6 +1161,41 @@
      return exist;
   }
   
   /**
    *    检查tb表是否存在
    * @param tb 表名不带数据库名
    * @return true:存在   false:不存在
    * @throws SQLException
    */
   public boolean sqlCheckIfTableExist(String tb)
   {
      String sql_str = " SELECT COUNT(*) as count FROM information_schema.TABLES " +
                   " WHERE table_name ='" + tb + "';";
      ResultSet res = sqlMysqlQuery(sql_str);
      boolean exist = false;
      try {
         if (null != res && res.next()) {
            int count = res.getInt("count");
            if(count > 0) {
               exist = true;
            }
         }
      } catch (Exception e) {
      } finally{
         if(null != res) {
            try {
               res.close();
            } catch (SQLException e) {
               e.printStackTrace();
            }
         }
      }
      return exist;
   }
   //执行sql语句
   public void sqlMysqlExecute(String sql_str) throws SQLException
   {
@@ -1191,11 +1230,9 @@
            }
            mysql_con.setAutoCommit(true);
         } catch (SQLException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
         }
      }
      return exe_res;
   }