"Juraj Kazda" <[EMAIL PROTECTED]> wrote:

>  Because code tables are almost (or long-time lasting) static
> data, I was thinking about putting a Vector of beans with attributes
> corresponding/matching the structure of code table. That means to make
> one start-up servlet which will fill all the Vectors of code tables and
> puts them in application scope context when the application starts. But
> there is a problem: how to access connection pool defined by
> struts-config.xml to obtain connection to database? Or dou you know how
> to solve the whole problem better?

You can either use JNDI connection pool. Or you can read the data in an
action and cache them then. I'd use the double checked singleton pattern:

Thing getThing() {
    if (null == this.thing) {
        synchronized(this) {
            if (null == this.thing) {
                // read the thing form the database
            }
        }
    }
    return thing;
}

Reply via email to