Java Reference
In-Depth Information
String fName = "fees.xml";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
CachedRowSet rowSet = new CachedRowSet();
PrintWriter out = new PrintWriter(new FileOutputStream(fName));
//set url,login and password;
rowSet.setUrl( url );
rowSet.setUsername( login );
rowSet.setPassword( password );
//set the sql command
rowSet.setCommand("Itemise_Fees 10001;");
//execute the command
rowSet.execute();
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
out.println(" <matter>");
// read the data and put it to the console
while(rowSet.next()){
out.println(" <fee>");
for(int j=1; j<=rowSet.getMetaData().getColumnCount(); j++){
out.print(" <"+
rowSet.getMetaData().getColumnLabel(j)+">");
out.print( rowSet.getObject(j));
out.println( "</"+rowSet.getMetaData().getColumnLabel(j)+">");
}
out.println(" </fee>");
}
out.println(" </matter>");
//close the RowSet
rowSet.close();
out.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
Search WWH ::




Custom Search