try {
DataSource ds =
(DataSource) OptionHelper.instantiateByClassName(dsClassName, DataSource.class, context);
PropertySetter setter = new PropertySetter(ds);
setter.setContext(context);
if (!OptionHelper.isEmpty(urlStr)) {
setter.setProperty("url", urlStr);
}
if (!OptionHelper.isEmpty(userStr)) {
setter.setProperty("user", userStr);
}
if (!OptionHelper.isEmpty(passwordStr)) {
setter.setProperty("password", passwordStr);
}
Context ctx = new InitialContext();
ctx.rebind("dataSource", ds);
} catch (Exception oops) {