You're welcome, if it did you any good.  I am not so well learned in the
fine art of database Connections myself, so i'm trying to gather what
information I can.  But regarding the time they take to establish, I was
just measuring it myself, and it looks to me as if it takes quite some time:

OUTPUT:
Connection created: 165
Statement created: 166
Query finished: 171
rs.next() called: 171
Bytes read: 188

Connection created: 454
Statement created: 459
Query finished: 538
rs.next() called: 538
Bytes read: 658

These are milliseconds, so in this case it took HALF A SECOND to create the
Connection.  That does add up.

ps. Do you know of an open-source pool, I believe we will have to use it.

CODE:
  long startTime = (new Date()).getTime();
        Class.forName ("oracle.jdbc.driver.OracleDriver");
        conn = DriverManager.getConnection ("jdbc:oracle:oci8:ncd", "dw302",
"odd");
        conn.setAutoCommit (false);
  System.out.println( "Connection created: " + ((new Date()).getTime() -
startTime) );
        stmt = conn.createStatement ();
  System.out.println( "Statement created: " + ((new Date()).getTime() -
startTime) );
        rs = stmt.executeQuery (sqlSelect);
  System.out.println( "Query finished: " + ((new Date()).getTime() -
startTime) );
        rs.next ();
  System.out.println( "rs.next() called: " + ((new Date()).getTime() -
startTime) );
        OracleBlob blob = ((OracleResultSet)rs).getBlob (1);
        byte[] bytes = readBlob(conn, blob, 256);
  System.out.println( "Bytes read: " + ((new Date()).getTime() -
startTime) );


----- Original Message -----
From: Kirkdorffer, Daniel <[EMAIL PROTECTED]>
To: 'Magn�s ��r Torfason' <[EMAIL PROTECTED]>
Sent: Wednesday, September 29, 1999 7:29 PM
Subject: RE: Re: Database Connections


Magnus,

You are right, the solution won't scale well.  But some solutions don't need
to scale.  We simply won't ever have that problem.  When that is a problem
for another application, then we will see what we need to do.  I'm sure the
DBAs will have a change of heart if we could implement a pool that would
maintain a limit on connections at any one time.  BTW, database connections
actually don't take that long to establish really, though.  Thanks for the
comments.

Dan

> ----------
> From: Magn�s ��r Torfason[SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, September 29, 1999 10:05 AM
> To: Kirkdorffer, Daniel
> Subject: Re:      Re: Database Connections
>
> We are using that approach (each bean has its own connection), and that is
> not scaling very well.  Am I not correct in thinking that there are two
> kinds of costs associated with Connections.
>
> 1) They take a long time to create
> 2) The DBMS can only sustain a limited number of them at the same time
>
> To me it seems that the bean approach will very quickly lead to
> overcrowding.  We use Oracle8i and it grinds to a halt when the connection
> count reaches 98.  For performance reasons, 1 connection per user is very
> restrictive (we use 4 Connection Beans per session), but even so, this
> leads
> to an absolute maximum of 98 users simultaneously.  That is surely not
> acceptable, so it seem to me that there are only two real options.
> 1) Create Connections on the fly (regardless of the performance issues)
> 2) Use a pool.
>
> The pool can easily be configured to time out, so that the connections die
> if they have not been used for some time, so as to keep your DBA happy : )
>
> Magnus Torfason
>
> ----- Original Message -----
> From: Kirkdorffer, Daniel <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, September 29, 1999 6:01 PM
> Subject: Re: Database Connections
>
>
> > A new instance of the LoginBean will be created for each session.  It
> would
> > be more appropriate for you to maintain your connection pool in another
> > class, and for your LoginBean to ask that class object for a new
> connection.
> > You should also consider how best to manage the connection pool so that
> it
> > appropriately recovers from a server shutdown or the like.
> >
> > Another, simpler, approach would be to have each LoginBean establish and
> > retain its own database connection.  The price of doing this is really
> only
> > going to be once, at login.  We looked at using connection pools, and
> for
> a
> > small number of connections it really didn't save us much on systems
> that
> > will not need to be scaled up.  In fact our DBAs said no to us even
> using
> > connection pools, and here they decide such things.  They didn't want a
> > bunch of open and unused connections sitting around.
> >
> > Probably rubs all the connection pool purists out there a little bit the
> > wrong way, but hey!
> >
> > Cheers,
> >
> > Dan
> > --
> > Daniel Kirkdorffer
> > NACN IS: 425-580-6225
> > Sr. Consultant, Syllogistics LLC
> > Email: [EMAIL PROTECTED]
> > Web:   http://www.syllogistics.com/
> >
> >
> > > ----------
> > > From:         Nanduri Amarnath[SMTP:[EMAIL PROTECTED]]
> > > Reply To:     [EMAIL PROTECTED]
> > > Sent:         Wednesday, September 29, 1999 7:13 AM
> > > To:   [EMAIL PROTECTED]
> > > Subject:      Database Connections
> > >
> > > Hi everybody,
> > >      I am using a LoginBean as a Session Object in my JSP pages.   The
> > > LoginBean
> > > takes user info and connects to a Database (where it validates the
> > > username and
> > > password).  I am using a ConnectionPool to maintain a pool of
> connections
> > > to a
> > > Database.  I am creating the ConnectionPool inside the constructor of
> the
> > > LoginBean.
> > >
> > >      My question is... If some 10 clients use my app.. will 10
> > > ConnectionPools
> > > be created ? If so, how can i overcome this to maintain only a single
> > > connection
> > > pool and have all my LoginBeans (sessions) access that pool.
> > >
> > > Forgive me if i am wrong...but i was under the impression that only a
> > > single
> > > LoginBean will be created on the server and all the JSP requests
> access
> > > that
> > > bean. If this is the case, then how can i maintain sessions for all
> the
> > > different users ?
> > >
> > >
> > > In servlets i used the  init() method to create my ConnectionPool. Is
> > > there
> > > anything like this method, that i can use in the JSP to create my
> > > ConnectionPool
> > > ?
> > >
> > > Thank you very much for your feedback.
> > >
> > > Cheers,
> > > Amar..
> > >
> > > [EMAIL PROTECTED]
> > >
> > >
> ==========================================================================
> > > =
> > > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > > JSP-INTEREST".
> > > FAQs on JSP can be found at:
> > >  http://java.sun.com/products/jsp/faq.html
> > >  http://www.esperanto.org.nz/jsp/jspfaq.html
> > >
> >
> >
> ==========================================================================
> =
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> > FAQs on JSP can be found at:
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.html
> >
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to