IBM Version 5 Universal Remote User Manual


 
Chapter 11. Light weight XML-based Enterprise Application 279
Example 11-14 setDatasourceMethods
/**
* Setting up datasource
* @param dsname String.
* @param dsclassname String DataSource class name
ex.COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource.
* @exception CMFactoryException
* @exception ClassNotFoundException
*/
public void setDataSource(String dsname, String dsclassname)
throws CMFactoryException,
ClassNotFoundException
{
java.util.Properties prop = new java.util.Properties();
prop.put(DataSourceFactory.NAME, dsname);
prop.put(DataSourceFactory.DATASOURCE_CLASS_NAME,dsclassname);
datasource = DataSourceFactory.getDataSource(prop);
}
/**
* Setting up datasource
* @param dsname String.
* @exception javax.naming.NamingException
*/
public void setDataSource(String dsname)
throws NamingException
{
java.util.Properties prop = new java.util.Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
Context ctx = new javax.naming.InitialContext(prop);
datasource = (DataSource)ctx.lookup(dsname);
}
Constructors
New constructors have a second parameter to set the datasouce. It accepts the
datasource itself or the datasource name.
Example 11-15 setDatasourceMethods
/**
* Constructor for SQLToXMLds.
*/
public SQLToXMLds(QueryProperties qprop, DataSource ds) {
super(qprop);