FileDocCategorySizeDatePackage
UseDataSourceTag.javaAPI DocExample2570Thu Jun 28 16:14:16 BST 2001com.ora.jsp.tags.sql

UseDataSourceTag

public 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.
author
Hans Bergsten, Gefion software
version
1.0

Fields Summary
private String
id
private String
driverClassName
private String
url
private String
user
private String
pw
Constructors Summary
Methods Summary
public intdoEndTag()
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 voidrelease()
Releases all instance variables.

        id = null;
        driverClassName = null;
        url = null;
        user = null;
        pw = null;
    
public voidsetClassName(java.lang.String driverClassName)
Sets the JDBC driver class name.

        this.driverClassName = driverClassName;
    
public voidsetId(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 voidsetPw(java.lang.String pw)
Sets the database account password, if needed.

        this.pw = pw;
    
public voidsetUrl(java.lang.String url)
Sets the JDBC URL.

        this.url = url;
    
public voidsetUser(java.lang.String user)
Sets the database account name, if needed.

        this.user = user;