Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2010
    Posts
    2

    Unanswered: which is correct

    hi all
    i am developing a desktop application which require connect to the DB every 1 sec so i am little confused abbout two things
    1- open a new connection every time i connect the server and then close it

    2- open one connection and never close

    so which one is the correct and why

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Either one could be correct, depending on what criteria are used to evaluate the "correctness" of the solution. Most database administrators and developers would open a connection and hold it open until it will be unused for a minute or more. You might also enable connection pooling, which will do the same thing "under the covers" if someone objects from the standpoint of pure code correctness.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Jul 2010
    Posts
    2
    thank you pat for your answer
    but let us evaluate the correctness by the load on the machine
    meaning which one will cause the biggest load on the machine noted that my machine have to be turned on 24 /7

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    At least in my mind and experience, neither of them ought to be noticeable. They are probably measurable if you take precise measurements of the right counters, but I doubt that anyone would ever notice.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •