67,513
社区成员
发帖
与我相关
我的任务
分享
String catalog = con.getCatalog();
DatabaseMetaData dmd = con.getMetaData();
ResultSet userTables =
dmd.getTables(catalog, null, null, new String[] {"TABLE"});
List<Table> list = new ArrayList<Table>();
try {
while(userTables.next()) {
String tableName = userTables.getString(Table.TABLE_NAME);
Table table = new Table();
table.setTableName(tableName);
if(!table.isBackupTable()) {
continue;
}
table.setCatalog(catalog);
table.setSchema(userTables.getString(Table.SCHEMA));
ResultSet primaryKeys = dmd.getPrimaryKeys(
catalog, table.getSchema(), tableName);
ResultSet tableColumns = dmd.getColumns(
catalog, table.getSchema(), tableName, null);
String sql = "SELECT * FROM " + tableName;
ResultSet allTableData = stmt.executeQuery(sql);
EntityBean bean = Mapping.getTable4bean().get(tableName);
Calendar c = Calendar.getInstance();
String currentMonth = Tool.dateFormat("yyyyMM", c.getTime());
c.add(Calendar.MONTH, -1);
String lastMonth = Tool.dateFormat("yyyyMM", c.getTime());
if(bean != null) {
List<BaseBean> beanList = select(sql);
list.add(select(sql));
}
catch(Exception e) {
e.printStackTrace();
}
finally {
allTableData.close();
primaryKeys.close();
tableColumns.close();
}
}
}
catch(Exception e) {
e.printStackTrace();
}
finally {
userTables.close();
}
return list;
}