Results 1 to 3 of 3
  1. #1
    Daniel is offline Member
    Join Date
    Jun 2007
    Rep Power

    Lightbulb Connection to data base

    Hello, I have a class that allows me to establish a connection with a data base and I have other classes singleton that uses the first that I described obtaining a connection. By each method in which I use the connection, first I open the data base, I use it and thenI close it.

    Something like this:

    Java Code:
    Connection conn = new Connection ();
    .............. something of code....... 
    This works, simply I want to know if it is correct to do it in this way, or if it is possible to improved it.

    Daniel :o

  2. #2
    Albert is offline Senior Member
    Join Date
    Jun 2007
    Rep Power


    hello! you could use singleton pattern, hereby you avoid, ( in case of having 500 users), to have 500 objects Connection thing that waste memory.


  3. #3
    Eric is offline Senior Member
    Join Date
    Jun 2007
    Rep Power


    If it is an application Web, and it is going to have many consults. I advise to you to read a little of Connection Pool to increase the performance and make the system more robust from the point of view of the concurrent consultations…
    The code that you showed didn't say a lot, because you encapsulate everything in Connection. of which there are no details…


Similar Threads

  1. no connection
    By even in forum JDBC
    Replies: 15
    Last Post: 01-02-2008, 02:50 PM
  2. Problems with Jtable connected to data base
    By elizabeth in forum AWT / Swing
    Replies: 2
    Last Post: 08-07-2007, 04:24 PM
  3. Replies: 1
    Last Post: 08-06-2007, 05:38 PM
  4. 2 threads sharing a data base connection
    By Ed in forum Advanced Java
    Replies: 2
    Last Post: 07-04-2007, 04:41 AM
  5. Data Source :How to get connection inside java
    By peiceonly in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 04-02-2007, 10:40 AM

Posting Permissions

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