Results 1 to 3 of 3
Thread: Connection to data base
- 06-07-2007, 04:50 AM #1
Member
- Join Date
- Jun 2007
- Posts
- 91
- Rep Power
- 0
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:
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.Java Code:Connection conn = new Connection (); conn.openBase(); .............. something of code....... conn.close();
Daniel :o
- 06-07-2007, 04:52 AM #2
Senior Member
- Join Date
- Jun 2007
- Posts
- 114
- Rep Power
- 0
hello! you could use singleton pattern, hereby you avoid, ( in case of having 500 users), to have 500 objects Connection thing that waste memory.
Albert
- 06-07-2007, 04:55 AM #3
Senior Member
- Join Date
- Jun 2007
- Posts
- 111
- Rep Power
- 0
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…
Eric
Similar Threads
-
no connection
By even in forum JDBCReplies: 15Last Post: 01-02-2008, 01:50 PM -
Problems with Jtable connected to data base
By elizabeth in forum AWT / SwingReplies: 2Last Post: 08-07-2007, 04:24 PM -
Problems when I try to connect to data base
By gabriel in forum JDBCReplies: 1Last Post: 08-06-2007, 05:38 PM -
2 threads sharing a data base connection
By Ed in forum Advanced JavaReplies: 2Last Post: 07-04-2007, 04:41 AM -
Data Source :How to get connection inside java
By peiceonly in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 04-02-2007, 10:40 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks