If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Join Date
    May 2005
    Rochester, NY
    Member #
    I have a database driven e-commerce website. I just wrote a page to display our products, in the page I call a half dozen different methods and I've written them to open a connection, execute a query, and then close the connection.

    As our user load increased I started recieving errors that say "to many database connections".

    So I am wondering is it better form to open a connection at the top of the script allow the methods to execute queries on it and then close it in the last line OR is it more proper to have it set up one connection per method, as it is now ?
    michael murphy
    Professional Web Development


  3. #2
    Senior Member
    Join Date
    May 2003
    Member #
    I cannot give you advice on if it is proper to close and re-open connections and what effect this will have on resources.

    However, if all queries run regardless of variable states (e.g. if a session is set or if i > 5) then it seems logical to open the connection at the beginning of the code (before any queries) and close (after the last query)

    That is assuming that the tables that these queries all exist on the same database.

    Hope this helps.

  4. #3
    Senior Member seanmiller's Avatar
    Join Date
    Sep 2003
    Glastonbury, UK
    Member #
    1 times
    Are you definitely closing your connections?

    I'm surprised it would say "too many database connections" if you're opening and closing straight away as that error message is meant to refer to current *open* connections, so you should only ever have one at a time open regardless of whether you have four, or four hundred open/close combinations.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT -6. The time now is 11:29 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: