List of usage examples for org.jdom2.contrib.input ResultSetBuilder setAsAttribute
public void setAsAttribute(int columnNum, String attribName)
Set a column as an Attribute
of a row using the column number.
From source file:ResultSetBuilderDemo.java
License:Open Source License
public static void main(String[] args) throws Exception { // Tested against Cloudscape database that comes with the J2EE ref impl Class.forName("COM.cloudscape.core.JDBCDriver"); Connection con = DriverManager.getConnection("jdbc:cloudscape:rsbd;create=true"); // Create and fill commands, needed only on the first run Statement prep = con.createStatement(); prep.executeUpdate(PREP);/* ww w . j a v a 2s .c o m*/ Statement fill = con.createStatement(); fill.executeUpdate(FILL); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select id, name, home_url || contact_phone from rsbd"); ResultSetBuilder builder = new ResultSetBuilder(rs); builder.setAsElement(3, "num3"); //builder.setNamespace(ns); //builder.setAsElement("id", "newid"); //builder.setAsElement("home_url", "newhome_url"); //builder.setAsElement(4, "some4"); //builder.setAsAttribute(4, "some4"); //builder.setAsAttribute("state_flag"); builder.setAsAttribute("created_time", "ctime"); Document doc = builder.build(); XMLOutputter outputter = new XMLOutputter(); outputter.output(doc, System.out); }