I'm actually using the code similar to the database conection pooling example
from wrox.com. I have a connection pool object that gets instantiated and added
to the Servlet Context on application load. The connection variables (username,
url, password, etc) are loaded from a properties file. The various pools are
then referenced via poolname. Then I wrote a Database Access Bean to get a
connection from the pool and perform the SQL proceedures. All of my other beans
just use the Database access bean and pass a reference to the ServletConfig (to
get the ServletContext object from) and the name of the pool to access.
like the following:
<snip>
MyObject thecontact = new MyObject();
String poolname = (String)this.sc.getServletContext().getAttribute("db.applet");

//note "sc" = the ServletConfig Object reference in this bean
dbAccessBean adb = new dbAccessBean(poolname, sc);
        ResultSet rs = null;
        boolean success = false;
        try{
            rs = adb.executeSP("Execute myProceedure 'myvariable1',
'myvariable2'");
           if(rs.next()){success = true;}
        }catch(Exception e){
            throw new Exception(e.toString());
        }finally{
            rs.close();
            adb.close();
        }
</snip>
Hope this helps
Matt

Ralph Fiol wrote:

> Matt,
> Your implementation sounds right on!  My vision for the e-commerce
> application does use beans for the data access, JPSs for presentation, and
> servlets for routing -- exactly as you have detailed.  Thanks for the
> insight.  My "home" page will display product categories (from a database --
> gathered by a Bean) and 3 randomly selected featured products (also produced
> by a bean).  I'll use the JSP index page to present the results gathered by
> these Beans.  Can you share with us an snippet of one of your JDBC-enabled
> beans?  I'm interested to learn how you've handled things like connection
> pooling and determining datasource names/uids/pwds.
>
> Thanks
> Ralph
>
> > Date: Wed, 10 Jan 2001 16:36:37 -0500
> > From: Matt Goss <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: Re: Good Example of Model 2 Architecture
> > Message-ID: <[EMAIL PROTECTED]>
> >
> > Ralph,
> > I'm currently implementing the Model 2 architechture in a web based
> application.
> > The application configures all of the customers, mailboxes, users, and
> trading
> > partner relationships for our e-commerce application (on a MSSQL 7
> Server).
> > The model I use, uses Beans for all data processing and database access.
> > Servlets for data routing (ie processing Post's and such) and JSP's for
> data
> > presentation and gathering. This works quite well for me. So, in answer to
> your
> > question... I would put all of you sql queries into a (JDBC enabled) bean
> and
> > then access the bean via your jsp pages (via the jsp:useBean and
> jsp:getProperty
> > tags)
> > Matt Goss
>
> Archives: http://www.mail-archive.com/[email protected]/
> Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to