从数据库读取数据,并生成xml文档
public void createXMLFile(String tableName, String sql, String filePath) throws Exception {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection
conn=DriverManager.getConnection("jdbc:oracle:thin:@IP:端口号:serviceName", 用户名, 密码);
IDatabaseConnection connection = new DatabaseConnection(conn);
QueryDataSet query = new QueryDataSet(connection);
query.addTable(tableName, sql);
XmlDataSet.write(query, new FileOutputStream(filePath));
}
util.createXMLFile("tbl_XXX", "select * from tbl_XXX where fileds in ('','') ", "E://file1.xml");
posted on 2013-01-08 15:10
JavaBird 阅读(207)
评论(0) 编辑 收藏 所属分类:
JAVA