package com.baishiji.action.task;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import com.baishiji.uploadrecord.db.Db;
public class CreadSql {
/*
* 分析 : 1.连接上数据库 , 2.创建 子表
*/
public boolean creadSo(String name) {
StringBuilder sb = new StringBuilder();
sb.append("create table o_task_run_"+name+" ( ");
sb.append("[id] [int] IDENTITY(1,1) NOT NULL,");
sb.append("[mobile] [varchar](30) NULL,");
sb.append("[contact] [varchar](20) NULL,");
sb.append("[call_status] [int] NULL,");
sb.append("[call_time] [datetime] NULL,");
sb.append("[call_billsec] [int] NULL,");
sb.append("[call_uniqueid] [varchar](20) NULL,");
sb.append("[tab_status] [int] NULL,");
sb.append("[customer_id] [int] NULL,");
sb.append("[extension] [int] NULL,");
sb.append("[author] [int] NULL,");
sb.append("[action_id] [varchar](20) NULL,");
sb.append("[date_from_type] [char](12) NULL,");
sb.append("[date_from_code] [varchar](32) NULL,");
sb.append("[addtime] [datetime] NULL,");
sb.append("[del] [int] NULL,");
sb.append("[task_id] [int] NULL,");
sb.append("[remark] [varchar](255) NULL,");
sb.append("[address] [varchar](255) NULL");
sb.append(")");
Connection conn = null;
Statement stat = null;
try {
Db db = Db.getDb();
conn = db.getConnection();
stat = conn.createStatement();
// 创建表test
stat.executeUpdate(sb.toString());
stat.close();
conn.close();
return true;
} catch (SQLException e) {
e.printStackTrace();
return false;
} finally {
if (stat != null) {
try {
stat.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
}
}
}
}
}
}
}
java 创建 数据库 表
最新推荐文章于 2024-09-09 16:59:00 发布