package com.database_util;
|
|
import java.sql.SQLException;
|
|
import com.sql.MysqlConnPool;
|
import com.sql.Sql_Mysql;
|
|
public class DB_User {
|
|
public static void init(MysqlConnPool pool, boolean recreate) {
|
//´´½¨Êý¾Ý¿â
|
createDB_User(pool);
|
|
createBaoJiGroup_Table(pool, recreate);
|
|
createBattGroup_BaoJiGroup_Table(pool, recreate);
|
|
createBattGroup_Usr_Table(pool, recreate);
|
|
createOperation_Log_Table(pool, recreate);
|
|
createUser_Inf_Table(pool, recreate);
|
|
createTemp_Numbers_Table(pool, recreate);
|
}
|
|
/**
|
* ´´½¨ tb_baojigroup
|
* @param pool
|
* @param recreate
|
*/
|
public static void createBaoJiGroup_Table(MysqlConnPool pool, boolean recreate) {
|
String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BaoJiGroup_Table;
|
String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BaoJiGroup_Table + " (" +
|
" `num` int(20) NOT NULL AUTO_INCREMENT," +
|
" `baoji_group_id` int(20) DEFAULT '0'," +
|
" `baoji_group_name` varchar(200) NOT NULL DEFAULT '0'," +
|
" PRIMARY KEY (`num`)" +
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
if(true == recreate) {
|
sql.sqlMysqlExecute(sql_str01);
|
}
|
sql.sqlMysqlExecute(sql_str02);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ´´½¨ tb_battgroup_baojigroup
|
* @param pool
|
* @param recreate
|
*/
|
public static void createBattGroup_BaoJiGroup_Table(MysqlConnPool pool, boolean recreate) {
|
String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattGroup_BaoJiGroup_Table;
|
String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattGroup_BaoJiGroup_Table + " (" +
|
" `num` bigint(20) NOT NULL AUTO_INCREMENT," +
|
" `baoji_group_id` int(11) NOT NULL DEFAULT '0'," +
|
" `dev_id` int(11) NOT NULL DEFAULT '0'," +
|
" PRIMARY KEY (`num`)," +
|
" KEY `index_group_id` (`baoji_group_id`)" +
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
if(true == recreate) {
|
sql.sqlMysqlExecute(sql_str01);
|
}
|
sql.sqlMysqlExecute(sql_str02);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ´´½¨ tb_battgroup_usr
|
* @param pool
|
* @param recreate
|
*/
|
public static void createBattGroup_Usr_Table(MysqlConnPool pool, boolean recreate) {
|
String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattGroup_Usr_Table;
|
String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattGroup_Usr_Table + " (" +
|
" `num` bigint(20) NOT NULL AUTO_INCREMENT," +
|
" `baoji_group_id` int(11) NOT NULL DEFAULT '0'," +
|
" `uid` int(11) NOT NULL DEFAULT '0'," +
|
" PRIMARY KEY (`num`)," +
|
" KEY `index_group_id` (`baoji_group_id`)" +
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
if(true == recreate) {
|
sql.sqlMysqlExecute(sql_str01);
|
}
|
sql.sqlMysqlExecute(sql_str02);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ´´½¨ tb_operation_log
|
* @param pool
|
* @param recreate
|
*/
|
public static void createOperation_Log_Table(MysqlConnPool pool, boolean recreate) {
|
String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Operation_Log_Table;
|
String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Operation_Log_Table + " (" +
|
" `id` int(11) NOT NULL AUTO_INCREMENT," +
|
" `user_id` int(11) DEFAULT NULL," +
|
" `user_name` varchar(45) DEFAULT NULL," +
|
" `type1` int(11) DEFAULT NULL COMMENT 'ʼþÀàÐÍ:1-ϵͳ¼¶,2-ÒµÎñ¼¶'," +
|
" `type2` int(11) DEFAULT NULL COMMENT 'ʼþÀàÐÍ:×Ó¼¶±ð'," +
|
" `msg` varchar(45) DEFAULT NULL COMMENT '»ù´¡ÐÅÏ¢'," +
|
" `detail` varchar(21000) DEFAULT NULL COMMENT 'ÏêϸÐÅÏ¢'," +
|
" `ip` varchar(45) DEFAULT NULL COMMENT '²Ù×÷µÄip'," +
|
" `create_time` datetime DEFAULT NULL," +
|
" PRIMARY KEY (`id`)" +
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Óû§²Ù×÷ÈÕÖ¾';";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
if(true == recreate) {
|
sql.sqlMysqlExecute(sql_str01);
|
}
|
sql.sqlMysqlExecute(sql_str02);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ´´½¨ tb_user_inf
|
* @param pool
|
* @param recreate
|
*/
|
public static void createUser_Inf_Table(MysqlConnPool pool, boolean recreate) {
|
String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.User_Inf_Table;
|
String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.User_Inf_Table + " (" +
|
" `uid` int(11) NOT NULL AUTO_INCREMENT," +
|
" `uname` varchar(64) NOT NULL DEFAULT '0' COMMENT 'Óû§Ãû×Ö'," +
|
" `usnid` varchar(1000) NOT NULL DEFAULT '0' COMMENT 'Óû§ÃÜÂë'," +
|
" `udownload_role` int(16) NOT NULL DEFAULT '0' COMMENT 'ÏÂÔØÈ¨ÏÞ'," +
|
" PRIMARY KEY (`uid`)" +
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
if(true == recreate) {
|
sql.sqlMysqlExecute(sql_str01);
|
}
|
sql.sqlMysqlExecute(sql_str02);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ´´½¨ temp_numbers
|
* @param pool
|
* @param recreate
|
*/
|
public static void createTemp_Numbers_Table(MysqlConnPool pool, boolean recreate) {
|
String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Temp_Numbers_Table;
|
String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Temp_Numbers_Table + " (" +
|
" `unumber` int(11) DEFAULT NULL" +
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
if(true == recreate) {
|
sql.sqlMysqlExecute(sql_str01);
|
}
|
sql.sqlMysqlExecute(sql_str02);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
|
|
public static void createDB_User(MysqlConnPool pool) {
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_USER);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
}
|