Using WebRowSet to create XML file from JOBS table

Last Modified On : 2-july-2008

import java.sql.*;
import javax.sql.*;
import oracle.jdbc.rowset.*;
import java.io.*;

public class WebRowSetDemo {
    public static void main(String[] args) throws Exception{
        OracleWebRowSet rs = new OracleWebRowSet();
        rs.setUrl("jdbc:oracle:thin:@localhost:1521:XE");
        rs.setUsername("hr");
        rs.setPassword("hr");
        rs.setCommand("select * from jobs");
        rs.execute();
        // write to XML
        FileWriter fw = new FileWriter("c:\\jobs.xml");
        rs.writeXml(fw);
        rs.close();
    }
}