Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-07-2007, 06:50 AM
Member
 
Join Date: Jun 2007
Posts: 92
Daniel is on a distinguished road
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:

Code:
Connection conn = new Connection (); conn.openBase(); .............. something of code....... conn.close();
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-07-2007, 06:52 AM
Senior Member
 
Join Date: Jun 2007
Posts: 114
Albert is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-07-2007, 06:55 AM
Senior Member
 
Join Date: Jun 2007
Posts: 111
Eric is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
no connection even Database 15 01-02-2008 03:50 PM
Problems with Jtable connected to data base elizabeth AWT / Swing 2 08-07-2007 06:24 PM
Problems when I try to connect to data base gabriel Database 1 08-06-2007 07:38 PM
2 threads sharing a data base connection Ed Advanced Java 2 07-04-2007 06:41 AM
Data Source :How to get connection inside java peiceonly JavaServer Pages (JSP) and JSTL 1 04-02-2007 12:40 PM


All times are GMT +3. The time now is 01:54 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org