package com.database_util;
|
|
import java.sql.SQLException;
|
import java.util.Date;
|
|
import com.base.Com;
|
import com.sql.MysqlConnPool;
|
import com.sql.Sql_Mysql;
|
|
public class DB_User {
|
public static void init(MysqlConnPool pool, boolean recreate) {
|
System.out.println(" db_user init start at " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
|
createDB_User(pool);
|
|
|
createOperation_Log_Table(pool, recreate);//´´½¨±ítb_ckpowerdev_alarm
|
|
createUser_Inf_Table(pool, recreate);//´´½¨±ítb_ckpowerdev_alarm
|
|
createTemp_Numbers_Table(pool, recreate);//´´½¨±ítb_ckpowerdev_alarm
|
|
|
System.out.println(" db_user init end at " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
}
|
|
/**
|
* ´´½¨ db_user Êý¾Ý¿â
|
* @param pool
|
*/
|
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();
|
}
|
}
|
|
/**
|
*
|
* @Title: createOperation_Log_Table
|
* @Description: ½¨±ítb_operation_log
|
* @param pool
|
* @param recreate
|
* @author author
|
* @date 2024Äê4ÔÂ1ÈÕ
|
*/
|
private 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 AUTO_INCREMENT=1468 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();
|
}
|
}
|
/**
|
*
|
* @Title: createUser_Inf_Table
|
* @Description: ½¨±ítb_user_inf
|
* @param pool
|
* @param recreate
|
* @author author
|
* @date 2024Äê4ÔÂ1ÈÕ
|
*/
|
private 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(255) NOT NULL DEFAULT '0' COMMENT 'Óû§ÃÜÂë'," +
|
" `udownload_role` int(16) NOT NULL DEFAULT '0' COMMENT 'ÏÂÔØÈ¨ÏÞ'," +
|
" PRIMARY KEY (`uid`)" +
|
") ENGINE=InnoDB AUTO_INCREMENT=1012 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();
|
}
|
}
|
/**
|
*
|
* @Title: createTemp_Numbers_Table
|
* @Description: ½¨±ítemp_numbers
|
* @param pool
|
* @param recreate
|
* @author author
|
* @date 2024Äê4ÔÂ1ÈÕ
|
*/
|
private 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();
|
}
|
}
|
|
}
|