package com.chinaops.db.core;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.chinaops.db.entity.Dept;
import com.chinaops.db.util.Conn;
public class CreateTable {
/*
public static final String Y_RACENTER_USER = "root";
public static final String Y_RACENTER_PASS = "root";
public static final String Y_RACENTER_URL = "jdbc:mysql://localhost:3306/ecloud_auth";
public static final String Y_METADATE_USER = "root";
public static final String Y_METADATE_PASS = "root";
public static final String Y_METADATE_URL = "jdbc:mysql://localhost:3306/ecloud_metadata";
public static final String Y_BILLING_USER = "root";
public static final String Y_BILLING_PASS = "root";
public static final String Y_BILLING_URL = "jdbc:mysql://localhost:3306/ecloud_billing";
public static final String M_USER = "root";
public static final String M_PASS = "root";
public static final String M_URL = "jdbc:mysql://localhost:3306/ecloud_billing";
*/
public static final String Y_RACENTER_USER = "racenter";
public static final String Y_RACENTER_PASS = "china-ops";
public static final String Y_RACENTER_URL = "jdbc:mysql://172.16.56.62:3306/ecloud_auth";
public static final String Y_METADATE_USER = "metadata";
public static final String Y_METADATE_PASS = "china-ops";
public static final String Y_METADATE_URL = "jdbc:mysql://172.16.56.64:3306/ecloud_metadata";
public static final String Y_BILLING_USER = "billing";
public static final String Y_BILLING_PASS = "china-ops";
public static final String Y_BILLING_URL = "jdbc:mysql://172.16.56.74:3306/ecloud_billing";
public static final String M_USER = "billing";
public static final String M_PASS = "china-ops";
public static final String M_URL = "jdbc:mysql://172.16.56.74:3306/ecloud_billing";
public static void main(String[] args) {
CreateTable c = new CreateTable();
// ***Tables 为写入如数据的操作,数据库连接的是目标数据,方法内调用了***SQL
// ***SQL 为查询要写入数据的sql语句,数据库连接的是源数据
c.createTables();
c.insertSQLTable();
c.updateResourcesTable();
c.updateOrderTable();
/*
List<String> b = c.updateResourcesSQL();
int j = 0;
if(b != null && b.size()>0){
for(String s:b){
System.out.println(j+" ** "+s);
j++;
}
}
List<String> orders = c.updateOrderSQL();
if(orders != null && orders.size()>0){
for(int i=0;i<orders.size();i++){
System.out.println(i+" ** "+orders.get(i));
if(i%19 == 0 && i != 0){
System.out.println("--------------------------------------------------------------------------------------------------------------------");
}
j++;
}
}
System.out.println("================================================ "+j+" ================================================");
*/
}
// OK
public void createTables(){
CheckTable ct = new CheckTable();
// 要构建的数据库的SQL语句信息
// String userName = "billing";
// String password = "china-ops";
// String url = "jdbc:mysql://172.16.56.74:3306/ecloud_billing";
Connection conn = null;
Statement stmt = null;
if(!ct.isExist(M_USER,M_PASS,M_URL,"company_res_order_cfg")){
try {
conn = Conn.getConn(M_URL, M_USER, M_PASS);
stmt = conn.createStatement();
String sql="CREATE TABLE company_res_order_cfg ("+
"id int(11) NOT NULL AUTO_INCREMENT,"+
"company_id varchar(25) DEFAULT NULL COMMENT '公司ID',"+
"max_instances int(11) DEFAULT '0' COMMENT '最大云主机数量',"+
"max_volumes int(11) DEFAULT '0' COMMENT '最大存储数量',"+
"max_snapshots int(11) DEFAULT '0' COMMENT '最大快照数量',"+
"min_ebs_size int(11) DEFAULT '0' COMMENT '最小ebs启动存储大小',"+
"max_ebs_size int(11) DEFAULT '0' COMMENT '最大ebs启动存储大小',"+
"max_security_groups int(11) DEFAULT '0' COMMENT '最大安全规则组(虚拟网络防火墙)数量',"+
"max_keypairs int(11) DEFAULT '0' COMMENT '最大密钥数量',"+
"ecu_mon_count float(11,0) DEFAULT '0' COMMENT 'ECU产品(ecu)包月数量',"+
"vol_mon_size int(11) DEFAULT '0' COMMENT '存储产品(volume)包月大小',"+
"snap_mon_size int(11) DEFAULT '0' COMMENT '快照产品(snapshot)包月大小',"+
"ha_mon_count int(11) DEFAULT '0' COMMENT 'HA(主机保护)产品(ha)包月数量',"+
"elb_mon_count int(11) DEFAULT '0' COMMENT 'Elb产品(elb)包天数量',"+
"ip_mon_count int(11) DEFAULT '0' COMMENT 'IP产品(ip)包月数量',"+
"ecu_day_count float(11,0) DEFAULT '0' COMMENT 'ECU产品(ecu)包天数量',"+
"vol_day_size int(11) DEFAULT '0' COMMENT '存储产品(volume)包天小大',"+
"snap_day_size int(11) DEFAULT '0' COMMENT '快照产品(snapshot)包天小大',"+
"ecu_hour_count float(11,0) DEFAULT '0' COMMENT 'ECU产品(ecu)计时数量',"+
"vol_hour_size int(11) DEFAULT '0' COMMENT '存储产品(volume)计时小大',"+
"snap_hour_size int(11) DEFAULT '0' COMMENT '快照产品(snapshot)计时大小',"+
"create_time datetime DEFAULT NULL COMMENT '创建时间',"+
"update_time datetime DEFAULT NULL COMMENT '更新时间',"+
"PRIMARY KEY (id)"+
") ENGINE=MyISAM AUTO_INCREMENT=86 DEFAULT CHARSET=utf8;";
System.out.println(stmt.executeUpdate(sql)+" "+sql);
} catch (SQLException e) {
e.printStackTrace();
}finally{
try{
stmt.close();
conn.close();
}catch(Exception ex){
ex.getStackTrace();
}
}
}else{
try {
conn = Conn.getConn(M_URL, M_USER, M_PASS);
stmt = conn.createStatement();
String dropsql = "DROP TABLE IF EXISTS company_res_order_cfg;";
System.out.println(stmt.executeUpdate(dropsql)+" "+dropsql);
String sql="CREATE TABLE company_res_order_cfg ("+
"id int(11) NOT NULL AUTO_INCREMENT,"+
"company_id varchar(25) DEFAULT NULL COMMENT '公司ID',"+
"max_instances int(11) DEFAULT '0' COMMENT '最大云主机数量',"+
"max_volumes int(11) DEFAULT '0' COMMENT '最大存储数量',"+
"max_snapshots int(11) DEFAULT '0' COMMENT '最大快照数量',"+
"min_ebs_size int(11) DEFAULT '0' COMMENT '最小ebs启动存储大小',"+
"max_ebs_size int(11) DEFAULT '0' COMMENT '最大ebs启动存储大小',"+
"max_security_groups int(11) DEFAULT '0' COMMENT '最大安全规则组(虚拟网络防火墙)数量',"+
"max_keypairs int(11) DEFAULT '0' COMMENT '最大密钥数量',"+
"ecu_mon_count float(11,0) DEFAULT '0' COMMENT 'ECU产品(ecu)包月数量',"+
"vol_mon_size int(11) DEFAULT '0' COMMENT '存储产品(volume)包月大小',"+
"snap_mon_size int(11) DEFAULT '0' COMMENT '快照产品(snapshot)包月大小',"+
"ha_mon_count int(11) DEFAULT '0' COMMENT 'HA(主机保护)产品(ha)包月数量',"+
"elb_mon_count int(11) DEFAULT '0' COMMENT 'Elb产品(elb)包天数量',"+
"ip_mon_count int(11) DEFAULT '0' COMMENT 'IP产品(ip)包月数量',"+
"ecu_day_count float(11,0) DEFAULT '0' COMMENT 'ECU产品(ecu)包天数量',"+
"vol_day_size int(11) DEFAULT '0' COMMENT '存储产品(volume)包天小大',"+
"snap_day_size int(11) DEFAULT '0' COMMENT '快照产品(snapshot)包天小大',"+
"ecu_hour_count float(11,0) DEFAULT '0' COMMENT 'ECU产品(ecu)计时数量',"+
"vol_hour_size int(11) DEFAULT '0' COMMENT '存储产品(volume)计时小大',"+
"snap_hour_size int(11) DEFAULT '0' COMMENT '快照产品(snapshot)计时大小',"+
"create_time datetime DEFAULT NULL COMMENT '创建时间',"+
"update_ti
java代码操作数据转移,把一个数据库里的东西移动到另一个数据库,自动建库建表
4星 · 超过85%的资源 需积分: 50 81 浏览量
2014-07-24
16:25:22
上传
评论 4
收藏 21KB ZIP 举报
JungleRoco1
- 粉丝: 6
- 资源: 8
最新资源
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
前往页