Paul Bye

+ Follow
since Oct 25, 2005
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Bye

Thanks for the reply. After some more thought I've realised it's not as simple as I hoped for.

I'm currently reading up on XATransactions, XADataSources, etc. One of the most confusing Java things I've come across yet.
We need to query/write to two different databases (one mySQL, one Sybase) within the same transaction. I've been reading up on this on Sun's website and google but all the information I can find is related to global transactions running within a J2EE app server.

Our application does not run on a J2EE app server and handles all the connection management and transactions itself.

Can the issue of updating multiple databases be as simple as the code I have written below or am I forgetting something?

any help appreciated thanks.

Originally posted by Bob Nedwor:
Will you take the SCWCD exam next?

I took and passed SCWCD on the same day I took SCJD. SCBCD is next but I'm going to take a few weeks break first.
18 years ago
Just found my results on the certmanager site. A little bit confused by the scoring but it has a P next to it so I assume I've passed.

This report shows the total points that could have been awarded in each section, and the actual number of points you were awarded. This is provided to give you per-section feedback on your strengths.

The maximum possible score is 155; the minimum to pass is 124.

General Considerations (maximum = 10): 8
Documentation (maximum = 7): 7
O-O Design (maximum = 3): 3
GUI (maximum = 4): 3
Locking (maximum = 8): 4
Data store (maximum = 4): 4
Network server (maximum = 4): 4
18 years ago
Don't think I've posted a message in this forum before but I've been lurking here for a month or two now. Took the SCJD and SCJWCD exams yesterday. Passed SCJCD with ~77%. My exam preperation was probably slightly different to most other people on here. I got the HFSJ book and found it really useful but started to run out of time before the exam and only read about 1/3 of it. I then started taking practice test after practice test and for each question I got wrong I'd research the answer in HFSJ and just learn the sections I was weak on.

I found and really useful for the practice tests. The actual exam I sat caught we offguard with a few of the questions that I wasn't really expecting, I seemed to have loads about HTTP methods other than GET and POST that really didn't seem relevent to the exam. I also had a few tricky questions regarding EL. The design pattern questions were great and are an easy way to pick up marks as they only take a few seconds to read and choose the correct answer.

So... see you in the SCBCD and SCWSD forums.
Thanks for the reply. I'll takr a look at the JGoodies framework. I've always been impressed with various JGoodies APIs when I've used them before.

I've bodged a temporary solution for the moment by creating a seperate Object I've called EditSession and having my various GUI components observe this. Then whenever another component makes a change to the model if can post a 'message' to the EditSession and the other components can choose to react if they want to. Not the most elegant of solutions but it works for the moment.
18 years ago
I was hoping someone could suggest a few possible solutions to my problem.

I have an object of class A which contains a few properties and a list of objects of type B. The type B objects contain a few properties and a list of object of type C which in turn contain their own properties.

I'm writing a part of a GUI which has to allow users to change this A object (which will involve changing the B and C objects). I'm struggling to find an elegant way of coding this. The GUI is fairly complicated but has to be to allow the users enough flexibility in editting these objects. E.g. The main screen displays and allows the editting of some of the properties of A along with a table/list of the B objects. When the user selects one or more B objects in the table part of the GUI displays these objects so the user can make changes to the B and possible C parts. As these various properties are changed other parts of the GUI have to be updated to reflect the changes.

I started out making A extend Observable so if one part of the GUI makes changes to it the other parts know to redisplay the new data if appropriate. The problem I am facing is what to do with the B and C parts. E.g. if the user changes a property of C and this change has to be reflected elsewhere in the GUI how do I propagate this change to the various GUI parts.

One option is to make B and C also Observable but I see this becoming a bit of a nightmare to maintain as B's and C's are added a removed, selected and deselected, etc. having to add and remove Observers to listen for changes to these.

Another solution would be to have the A object listen to changes in the B object and the B objects listen to changes in the C objects then B nofity A of the change and A notify it observers of this change?

Or an alternative approach would be to hard code these 'events' in the GUI. E.g. when something happens in one part of the GUI have something like parent.getTablePanel().refreshCurrentRow() to have this change redrawn in another component, etc.

I don't like any of these solutions as they all seem messy. Is there any set way or best practice / design pattern someone could point me in the direction of to solve this kind of problem?

Any help appreciated, thanks.
18 years ago

And what happens when recNo is negative in your method(s) ?

Thanks, I'd overlooked that. :roll:
Thanks for the reply.

I guess I could remove the synchronized block in recordExists but then I would have to ensure that any call to recordExists occurs within a synchronized block to stop two threads trying to use the dataFile object similtaneously (dataFile is an instance of RandomAccessFile).

An alternative could be to load all the record data (included byte flag) before checking flag validity.

If I were to do this then I would end up duplicating code within all the other methods that check a record exists.

I think I'll make the recordExists method private and add a comment detailing its use.

Thanks, Paul

Imagine the follow code.

The problems I see are...

In readRecord1 there is a chance that another thread could delete the record inbetween the recordExists and the actual read.

If I try and rectify this problem in readRecord2 then I am synchronizing on dataFile twice.

My question is 'is synchronizing on the same object twice in this way going to cause a problem?'

An alternative would be to lock the record, which I don't really want to do for reads.

Any suggestions? Thanks