The other two important pieces to database application flow are
connection and disconnection. It stands to reason that before you
actually issue a query, you should first connect to the database. It
is not uncommon, however, for people to forget the other piece of the
puzzle -- cleaning up after themselves. You should always free up
any database resources you grab the minute you are done with them. In
a long-running application like an Internet daemon process, a badly
written system can eat up database resources until it locks up the
system.