Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 30th, 2002, 12:47 AM
TEMM TEMM is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 7 TEMM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Entity Objects

Ok, I'm writing a Content Management System for an upcoming website, and I am currently working on writing classes for doing database access, more specifically, loading and saving user information.

What i have now is a class User, which contains a users username, password, and userid.

3 different constructors allow it to be instantiated using a username, userid, or a blank object for creating a new user. Also passed into the constructor is a Connection object, which is the database connection being used for the Entity Object. This allows the objects save and load methods to access the database without actually setting up the connection within the class.

My biggest question is, is that a good way of doing this? I think it will make the code in my jsp pages and servlets much easier to read, as well as cut down on redundant code, because all the mundane and messy operations which are used alot are kept hidden for the most part.

Reply With Quote
  #2  
Old December 30th, 2002, 06:16 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
That doesn't sound too bad.

Have you looked into connection pooling at all? It's way more efficient, and kind of takes care of what you're trying to accomplish. Some app servers can set up connection pools for you (more efficient that way), or you can create them yourself. Basically, this gives you a single class that manages all your connections, then you just grab a connection when you need it, and return it to the pool when you're done. It removes the overhead of making a fresh connection each time, plus it allows for multiple connections (you decide how many), to be made simultaneously. Your app will be faster for multiple users that way.
__________________
-james

Reply With Quote
  #3  
Old December 30th, 2002, 09:54 AM
TEMM TEMM is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 7 TEMM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Oooh, That sounds cool, dyou have a link to a tutorial for setting that up?

Reply With Quote
  #4  
Old December 30th, 2002, 04:02 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Well, if you're going to write your own, you can try this: http://builder.com.com/article.jhtm...011212kev02.htm

If you're using tomcat 4.1 here's some help on using the built-in functionality. You should be able to set everything up through the admin utility, though.
http://jakarta.apache.org/tomcat/to...ples-howto.html

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Entity Objects


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT