void test() {
DriverManagerDataSource ds = new DriverManagerDataSource();
ds.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver");
ds.setUrl("jdbc:derby:C:/projects/S2oSandBox/sm/SMdirect");
ds.setUsername("sa");
ds.setPassword("");
new MyStoredProcedure(ds).export("select * from sm_event",
"c:/projects/awards.txt", ',', ',', "UTF-8");
}
private class MyStoredProcedure extends StoredProcedure {
MyStoredProcedure(DataSource ds) {
logger.info("eventLogQuery constructor");
setDataSource(ds);
setFunction(true);
setSql("SYSCS_UTIL.SYSCS_EXPORT_QUERY");
logger.info("eventLogQuery setSql(SQL)");
declareParameter(new SqlParameter("query", Types.VARCHAR));
declareParameter(new SqlParameter("path", Types.VARCHAR));
// You'll have to use the right types here
declareParameter(new SqlParameter("notUsed1", Types.CHAR));
declareParameter(new SqlParameter("notUsed2", Types.CHAR));
declareParameter(new SqlParameter("notUsed3", Types.VARCHAR));
compile();
logger.info
("eventLogQuery compile()");
}
public void export(String query, String path, char notUsed1,
char notUsed2, String notUsed3) {
Map inParams = new HashMap();
// Better to use constants for the param names here and above
inParams.put("query", query);
inParams.put("path", path);
inParams.put("notUsed1", notUsed1);
inParams.put("notUsed2", notUsed2);
inParams.put("notUsed3", notUsed3);
execute(inParams); // calls superclass
}
--
Thnx & Regards
Sharath
