1
我擁有帶有XML列的DB2數據庫。我想從中讀取數據並將每個XML保存爲單獨的文件。讀取java中的XML數據庫列
這裏是我的代碼的一部分:
final List<Map<String, Object>> myList = dbcManager.createQuery(query).getResultList();
int i=0;
for (final Map<String, Object> element : myList) {
i++;
String filePath = "C://elements//elem_" + i + ".xml";
File file = new File(filePath);
if(!file.exists()){
file.createNewFile();
}
BufferedWriter out = new BufferedWriter(new FileWriter(filePath));
out.write(element.get("columnId"));
out.close();
}
現在,我不得不排隊out.write錯誤(element.get( 「ColumnID的」));,因爲element.get( 「ColumnID的」)是一個對象類型,它應該是例如字符串。
而我的問題是:我應該將哪種類型轉換(轉換)element.get(「columnId」)以將其保存在xml文件中?
http://amolnpujari.wordpress.com/2008/04/12/db2-native-xml/可能有幫助 –