When to connect and disconnect Connection

From: Dino Cherian <inimss(at)yahoo(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: When to connect and disconnect Connection
Date: 2001-11-20 10:10:00
Message-ID: 20011120101000.65421.qmail@web21002.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi all,

I would like to know which one is the best method of
managing database connection in Java 1.3 (with
PostgreSQL 7.1.2 JDBC).

Option 1:
Connect to the database in the "main" function and
disconnect on program exit. Use it throughout the life
of the application. "Connect once and use for ever".

Option 2:
Connect to the database near the code that uses it
and disconnect after that block of code. "Use and
throw away".

Please help me.

Thanks
Dino

__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1

Browse pgsql-sql by date

  From Date Subject
Next Message Miguel Gonzalez 2001-11-20 13:02:53 Genetic algorithms
Previous Message Stephan Szabo 2001-11-20 08:10:16 Re: SELECT * FROM t where p or q;