datasource = ds;
}
/**
*Constructor for SQLToXMLds.
*/
public SQLToXMLds(QueryProperties qprop, String dsname) { super(qprop);
try{
setDataSource(dsname); }catch(NamingException e){
System.out.println(e);
}
}
Execute methods
All execute methods are overridden and try to get a connection through the datasource:
public void execute(String s0, String s1, String s2, String s3) throws Exception{
setConnection();
super.execute(s0,s1,s2,s3);
}
private void setConnection() throws SQLException{ if(datasource != null ){
super.setConnection(datasource.getConnection());
}
}
Once you created the code, modify your servlet to use the SQLToXMLds, XMLToSQLds instead of SQLToXML and XMLToSQL. You need to define the datasource in the WebSphere Test Environment setting, and need to add the datasource name where you are invoking the constructor of them. Now you can use datasource. You still need to set the QueryProperties or SQLProperties, jdbc driver name, loginid, password, and jdbcservernames are no longer needed.
SQLResult is also resolved in the execute method of XMLToSQLds class. The overrided execute class is doing this function as follows:
public void execute(Document doc, boolean continueOnSQLError)
throws SQLException, | // connection creation failed |
ClassNotFoundException, | // jdbc driver is missing |
IOException, | // invalid input stream |
SAXException, | // parse error |
ParserConfigurationException
280 The XML Files: Development of XML/XSL Applications Using WebSphere Studio