package com.sql.util;
|
|
import java.sql.SQLException;
|
|
import com.sql.MysqlConnPool;
|
import com.sql.Sql_Mysql;
|
|
public class Db_Param {
|
public static void init(MysqlConnPool pool) {
|
createDb_Param(pool);
|
|
createBattAlarm_Param_Table(pool);
|
|
createPowerAlarm_param_Table(pool);
|
}
|
|
public static void createPowerAlarm_param_Table(MysqlConnPool pool)
|
{
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
String sql_str_auto = "CREATE SEQUENCE IF NOT EXISTS " + Sql_Mysql.PowerAlarm_param_Table + "_auto" +
|
" INCREMENT 1" +
|
" MINVALUE 1" +
|
" MAXVALUE 9223372036854775807" +
|
" START 1" +
|
" CACHE 1;";
|
//´´½¨×ÔÔöÐòÁÐ
|
sql.sqlMysqlExecute(sql_str_auto);
|
|
String sql_str = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.PowerAlarm_param_Table + " "
|
+ "(num bigint NOT NULL DEFAULT nextval('" + Sql_Mysql.PowerAlarm_param_Table + "_auto'::regclass)," +
|
" power_id integer NOT NULL DEFAULT 1," +
|
" alm_id integer NOT NULL DEFAULT 1," +
|
" alm_level integer NOT NULL DEFAULT 1," +
|
" alm_en integer NOT NULL DEFAULT 1," +
|
" PRIMARY KEY (num)" +
|
")";
|
sql.sqlMysqlExecute(sql_str);
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.PowerAlarm_param_Table + " OWNER TO sysdba;");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.PowerAlarm_param_Table + ".alm_id IS '¸æ¾¯id';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.PowerAlarm_param_Table + ".num IS '×ÔÔöÖ÷¼ü';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.PowerAlarm_param_Table + ".power_id IS 'µçÔ´ID';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.PowerAlarm_param_Table + ".alm_id IS 'µçÔ´¸æ¾¯ID';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.PowerAlarm_param_Table + ".alm_level IS '¸æ¾¯µÈ¼¶';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.PowerAlarm_param_Table + ".alm_en IS '¸æ¾¯Ê¹ÄÜ[0-½ûÓà 1-ÆôÓÃ]';");
|
sql.sqlMysqlExecute("COMMENT ON TABLE " + Sql_Mysql.PowerAlarm_param_Table + " IS 'µçÔ´¸æ¾¯²ÎÊý±í';");
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
public static void createBattAlarm_Param_Table(MysqlConnPool pool)
|
{
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
String sql_str_auto = "CREATE SEQUENCE IF NOT EXISTS " + Sql_Mysql.BattAlarm_Param_Table + "_auto" +
|
" INCREMENT 1" +
|
" MINVALUE 1" +
|
" MAXVALUE 9223372036854775807" +
|
" START 1" +
|
" CACHE 1;";
|
//´´½¨×ÔÔöÐòÁÐ
|
sql.sqlMysqlExecute(sql_str_auto);
|
|
String sql_str = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattAlarm_Param_Table + " "
|
+ "(num integer NOT NULL DEFAULT nextval('" + Sql_Mysql.BattAlarm_Param_Table + "_auto'::regclass)," +
|
" alm_id integer NOT NULL DEFAULT 0," +
|
" alm_name character varying(50) NOT NULL COLLATE pg_catalog.\"default\" DEFAULT ' '::character varying," +
|
" alm_high_coe double precision NOT NULL DEFAULT '0'::double precision," +
|
" alm_low_coe double precision NOT NULL DEFAULT '0'::double precision," +
|
" alm_high_level integer NOT NULL DEFAULT 0," +
|
" alm_low_level integer NOT NULL DEFAULT 0," +
|
" alm_high_en integer NOT NULL DEFAULT 0," +
|
" alm_low_en integer NOT NULL DEFAULT 0," +
|
" PRIMARY KEY (num)" +
|
")";
|
sql.sqlMysqlExecute(sql_str);
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattAlarm_Param_Table + " OWNER TO sysdba;");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.BattAlarm_Param_Table + ".alm_id IS '¸æ¾¯id';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.BattAlarm_Param_Table + ".alm_name IS '¸æ¾¯Ãû³Æ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.BattAlarm_Param_Table + ".alm_high_coe IS 'ÉÏÏ޸澯ãÐÖµ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.BattAlarm_Param_Table + ".alm_low_coe IS 'ÏÂÏ޸澯ãÐÖµ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.BattAlarm_Param_Table + ".alm_high_level IS 'ÉÏÏ޸澯µÈ¼¶';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.BattAlarm_Param_Table + ".alm_low_level IS 'ÏÂÏ޸澯µÈ¼¶';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.BattAlarm_Param_Table + ".alm_high_en IS 'ÉÏÏ޸澯ʹÄÜ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.BattAlarm_Param_Table + ".alm_low_en IS 'ÏÂÏ޸澯ʹÄÜ';");
|
sql.sqlMysqlExecute("COMMENT ON TABLE " + Sql_Mysql.BattAlarm_Param_Table + " IS 'µç³Ø¸æ¾¯²ÎÊý±í';");
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
public static void createDb_Param(MysqlConnPool pool) {
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute("CREATE SCHEMA IF NOT EXISTS " + Sql_Mysql.DB_PARAM + " AUTHORIZATION sysdba");
|
} catch (SQLException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|