UseDataSourceTagpublic class UseDataSourceTag extends TagSupport This class is a custom action for making the JDBC 1.0 DriverManager
available to the other Database actions as a JDBC 2.0 SE DataSource,
saved in the application scope.
It's intended to be used only during development. In production,
it's much more efficient to let an application init servlet make
a DataSource that implements a connection pool available to the
other actions. |
Fields Summary |
---|
private String | id | private String | driverClassName | private String | url | private String | user | private String | pw |
Methods Summary |
---|
public int | doEndTag()Creates a DataSourceWrapper and saves it in the application
scope, unless one is already available.
DataSource ds = (DataSource)
pageContext.getAttribute(id, PageContext.APPLICATION_SCOPE);
if (ds == null) {
try {
ds = new DataSourceWrapper(driverClassName, url, user, pw);
}
catch (Exception e) {
throw new JspException("Can't create DataSource: " + e.getMessage());
}
pageContext.setAttribute(id, ds, PageContext.APPLICATION_SCOPE);
}
return EVAL_PAGE;
| public void | release()Releases all instance variables.
id = null;
driverClassName = null;
url = null;
user = null;
pw = null;
| public void | setClassName(java.lang.String driverClassName)Sets the JDBC driver class name.
this.driverClassName = driverClassName;
| public void | setId(java.lang.String id)Sets the id, i.e. the name to use for the DataSource
in one of the JSP scopes.
this.id = id;
| public void | setPw(java.lang.String pw)Sets the database account password, if needed.
this.pw = pw;
| public void | setUrl(java.lang.String url)Sets the JDBC URL.
this.url = url;
| public void | setUser(java.lang.String user)Sets the database account name, if needed.
this.user = user;
|
|