/*
Java, XML, and Web Services Bible
Mike Jasnowski
ISBN: 0-7645-4847-6
*/
import java.sql.*;
import java.io.*;
import org.apache.xml.serialize.*;
import org.w3c.dom.*;
import org.xml.sax.*;
public class XMLDBDOMRead {
public static void main (String[] args) {
try {
Class.forName("COM.cloudscape.core.JDBCDriver").newInstance();
Connection conn = DriverManager.getConnection(
"jdbc:cloudscape:GAMETRADER");
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM MANUALS");
while (rs.next()) {
int id = rs.getInt("GAMEID");
Document manual = (Document)rs.getObject("MANUAL");
// Serialize the Document to a String //
XMLSerializer serialize = new XMLSerializer(System.out,null);
serialize.serialize(manual);
}
} catch (Throwable e) {
System.out.println("exception thrown");
System.out.println(e);
}
}
}
|