aspose file tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Locking & DBConnection (Thread) Pooling Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "Locking & DBConnection (Thread) Pooling" Watch "Locking & DBConnection (Thread) Pooling" New topic
Author

Locking & DBConnection (Thread) Pooling

TNguyen
Greenhorn

Joined: Apr 02, 2001
Posts: 6
For those that passed the SCJD exam or that are working on the assignment, could you please indicate how you implemented the database record locking and database connection pooling (or thread pooling) ?
In particular, I have the following 3 questions:
1) I am using a HashMap to keep track of locked records. The HashMap keys are an Integer wrappers for the record #'s (of the locked records) and the HashMap values are Strings for the ID's of the corresponding clients that locked the records. I synchronized on the HashMap whenever I need to lock/unlock a record. Does anyone see any problem with this?
2) For thread-poolingl, I use a DBConnection class that is a Runnable thread. DBConnection gets passed a Data object along with the client's ID to use for tracking locked records. The run() method of the DBConnection class listens for new Data objects and execute their run methods acting as their surogate threads and getting recycled (i.e. A fixed number of DBConnection threads are recycled instead of creating new ones each time I need a DBConnection). I this a good approach to thread/database connection pooling?
3) How can I use the Observer pattern for the time consuming and resource intensive file operations in the Data class?
Thank you for all you help in advance.
Timothy Nguyen

------------------
 
IntelliJ Java IDE
 
subject: Locking & DBConnection (Thread) Pooling
 
Threads others viewed
Passed !!!!
passed SCJD with 360/400
Passed 364/400
Passed SCJD
Passed with 95%
developer file tools