This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes database entry for user defined classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "database entry for user defined classes" Watch "database entry for user defined classes" New topic
Author

database entry for user defined classes

nitinram agarwal
Ranch Hand

Joined: Jan 29, 2009
Posts: 83
Hi,
I have a requirement to make entry to the database for all the custom classes(other than standard ones provided by Java),whenever these are loaded in the application. I can think of the following approach

-- have static block in all the user defined classes
-- write the required database loading part in the static block.

Do you think that there is a better approach for this?

Regards
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
Moving to our databases forum.

I suggest you have classes which simply connect to the database, taking care of any concurrency problems. Then use those classes for all database access. I presume you have read the relevant Java™ Tutorials section?
 
wood burning stoves
 
subject: database entry for user defined classes
 
Similar Threads
Storage and retrieval of data - best option?
How put security check on constructor if it calls super?
Authenticating Users
Inner classes
static block