大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
public void convertAllTable(DataBase sourceDB, Connection oraConn,
Connection hsqlConn, SqlRecord record) throws Exception {
long time = System.currentTimeMillis();
// 建表并导入数据
System.out.println(“创建表” + record.getTableName());
if (null == oraConn) {
throw new Exception(“ORA–00942 table : ” + record.getTableName()
+ ” not exist.”);
}
// String theSql = getCreateTableStmt(oraConn, record);
TableInfo tableInfo = getCreateTableSQL(sourceDB, oraConn, record);
System.out.println(“get tableInfo”);
insertTableInfo(tableInfo,hsqlConn);
System.out.println(“save tableInfo”);
String theSql = tableInfo.getHsqldbCreatTableSQL();
System.out.println(“get table dll”);
// System.out.println(user+” :: “+theSql);
Statement hsqlStmt = hsqlConn.createStatement();
// System.out.println(theSql);
hsqlStmt.execute(theSql);
System.out.println(“table created”);
long time2 = System.currentTimeMillis();
System.out.println(“建表时间:”+(time2-time));
// hsqlStmt.close();
// // 添加主键
// String keySql = tableInfo.getHsqldbCreateKey();
// System.out.println(keySql);
// hsqlStmt.execute(keySql);
// hsqlStmt.close();
// 导入数据
convertData(oraConn, hsqlConn, record);
long time3 = System.currentTimeMillis();
System.out.println(“导入数据时间:”+(time3-time2));
// break;
// 创建索引
convertIndex(oraConn, hsqlConn, record);
System.out.println(“创建索引时间:”+(System.currentTimeMillis()-time3));
Constant.table_count++;
System.out.println(“convert tables count:”+Constant.table_count);
}
private void insertTableInfo(TableInfo tableInfo, Connection conn) {
try {
Statement stm = conn.createStatement();
String tableName = tableInfo.getTablename();
List cols = tableInfo.getColumns();
String front_sql = “INSERT INTO CCARE.UBHAVE_TABLEINFO” +
“( TABLE_NAME, COLUMN_NAME, COLUMN_TYPE, COLUMN_LENGTH,” +
” COLUMN_NULLABLE, COLUMN_SCALE, COLUMN_PRECISION )” +
“VALUES ( ‘”+tableName+”‘, ‘”;
// colname’, ‘coltype’, collength,collnullable , colscale, colpreci)
for(Column col:cols){
String name =col.getColumn_name();
String type =col.getColumn_stype();
int length = col.getColumn_length();
int nullable = col.getColumn_nullable();
int scale = col.getColumn_data_scale();
int precis = col.getColumn_precision();
String sql = front_sql+name+”‘, ‘”+type+”‘, “+length+”, “+nullable+”, “+scale+”, “+precis+”)”;
// System.out.println(sql);
stm.addBatch(sql);
}
stm.executeBatch();
stm.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/193758.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...