sbappend(enterFlag);
}
String str = sbtoString();
FileUtilitysaveStringToFile(filePath str false);
}
附錄:生成import腳本代碼示例:/**
* 創建裝載腳本
* @param conn
* @param creator 表創建者
* @param filePath
*/
public void createLoadFile(Connection connString creatorString filePath) throws Exception {
DBBase dbBase = new DBBase(conn);
String selectTableSql = select name from sysibmsystables where creator = + creator + and type=T;
try {
dbBaseexecuteQuery(selectTableSql);
} catch (Exception ex) {
throw ex;
} finally {
dbBaseclose();
}
DBResult result = dbBasegetSelectDBResult();
List list = new ArrayList();
while (resultnext()) {
String table = resultgetString();
listadd(table);
}
StringBuffer sb = new StringBuffer();
String enterFlag = \r\n;
for (int i = ; i < listsize();i++) {
String tableName = (String)listget(i);
sbappend(db \load from aa + StringvalueOf(i+)+ ixf of ixf into + tableName + COPY NO without prompting \);
sbappend(enterFlag);
}
String str = sbtoString();
FileUtilitysaveStringToFile(filePath str false);
}
附錄:export腳本示例db connect to testdb user test password test
db export to aaixf of ixf select * from table
db export to aaixf of ixf select * from table
db connect reset
附錄:import腳本示例db connect to testdb user test password test
db load from aaixf of ixf replace into table COPY NO without prompting
db load from aaixf of ixf replace into table COPY NO without prompting
db connect reset
[] []
From:http://tw.wingwit.com/Article/program/DB2/201311/21945.html