import java.sql.*; import oracle.sql.CLOB; import oracle.xml.sql.query.*; import oracle.xml.parser.v2.*; import java.net.URL; import java.io.*; import EnrollmentWriter; public class Enrollment { // For debugging this inside JServer public static void debug_main() throws Exception { CLOB[] clob = new CLOB[1]; getAsCLOB("12332",clob); TemporaryCLOB.free(Examples.getConnection(),(Clob)clob[0]); } // For running on the command line. public static void main (String args[]) throws Exception { if (args.length < 1) { System.err.println("usage: Enrollment schoolid"); System.exit(1); } Connection conn = Examples.getConnection(); EnrollmentWriter ew = new EnrollmentWriter(args[0],conn); ew.printXML(new PrintWriter(System.out)); conn.close(); } // For running inside a SQL Statement public static void getAsCLOB(String schoolId, CLOB[] clob ) throws Exception { Connection conn = Examples.getConnection(); EnrollmentWriter ew = new EnrollmentWriter(schoolId,conn); clob[0] = (CLOB)TemporaryCLOB.create(Examples.getConnection()); ew.printXML(new PrintWriter(clob[0].getCharacterOutputStream())); conn.close(); } } |