Paul Clapham

+ Follow
since Oct 14, 2005
Paul likes ...
Eclipse IDE Firefox Browser MySQL Database
Vancouver, Canada
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 Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Clapham

Well, first of all you don't make it show a prompt. You code should do that, since you're the one who knows what the prompt should look like.

About the context: it's always been obvious to me whether my code is in a context where popping up a dialog is appropriate. I didn't even know this attribute existed until today.

Tim Holloway wrote:Although creating what amounts to an anonymous outer instance just to get an inner instance from an external context seems to be a questionable practice to me.

But remember that the example came from a certification exam.
That docs page actually tells you what its purpose is, in the Field Summary section. You are on the right track, it says

If true, this URL is being examined in a context in which it makes sense to allow user interactions such as popping up an authentication dialog.

So, you didn't say why it was necessary to load the database into memory. Unless you have a good reason to do so, then don't.

And you said you planned to update the database and the in-memory version simultaneously. Also not a good idea since it complicates the code for no good reason.

And you didn't confirm that the database had a unique key to enforce the uniqueness of user-id plus goods-id, so I assume it doesn't. It should, otherwise programming errors will produce duplicates.
1 week ago
You haven't said what you plan to do with that data. Let's start with: Why do you need to load all of the data into memory?

And does the database enforce those key requirements? It should.
2 weeks ago
So you want your server to call that method. It's clear to me that you know how to write code to call the method. So there must be a reason why you haven't already done so.

Explaining that reason would be part of your question for the forum, I think. The code you posted doesn't explain what it's for or why it exists.
2 weeks ago
No, not at all. Just mention that you think there is an error in the book. You almost did that anyway, so there's no harm done.

Paul Crane wrote:I don't know whether I should understand it fully or not, but just want to.

There seems to be this idea going around which claims that understanding how something works internally makes you a better person somehow.

I have a lock on my front door. I put a key in it and turn it, then I can open the door. I don't know how the lock works internally. In my kitchen is a refrigerator. I know it has a motor which pushes hot air out and leaves cold air in, but I don't know how it does that. My world is full of things which have been provided to me by people who know what they are doing, and I don't feel the need to second-guess their work. Life is too short for that.
There's a Java implementation of SMB which I used extensively to copy files around a WAN consisting of a variety of systems. I don't recall it being an issue if shares weren't mounted and it's been several years since I did that, so I believe the shares were created within the Java code. I do remember having to provide the code with passwords for SMB addresses. It was open source so you should still be able to track it down.
2 weeks ago

D Connor wrote:I am actually surprised there is no built in logger within the Java SDK or Console etc.

The built-in logging for the Java JDK is found in the java.util.logging package. See for example a tutorial I found at or search for other tutorials.

I don't know why you favour native Java implementations, though. The native Java logging appeared in Java 4, I think, or at any rate a very long time ago, but it was universally ignored because superior implementations like log4j were already available.
In the XML you posted, an <entries> element has seven children. There are three <entry> elements and four white-space text elements; you may not have been aware of the latter. It looks to me like your code tries to add the new <entry> element as a child of the last of those seven elements, which is whitespace text. Text elements can't have children.

You need to add the new <entry> element as a new child of the <entries> element. You might also want to add another whitespace text element to make the resulting XML look nice, but don't do that until you are told to do so, as it doesn't change the meaning of the document.
3 weeks ago
Addition: This would appear to be the article he criticised.

I noticed it mentioned applets, which helps to explain why it is seriously outdated.
3 weeks ago
Yes, the database server is a program which runs on a computer, where the files are located which contain the database tables and supporting information. It listens for requests over the network and handles them in the usual way that network apps do. It will accept a connection request and subsequently deal with messages sent via that connection.

Now, all of that connecting and messaging on your end is taken care of by the JDBC driver, so you don't have to. But you at least have to tell the driver where to find the server -- what computer is it running on and what port is it listening on? Hence the JDBC URL. Host name and port number are the only required information, but most drivers support a variety of other information.
Looks to me like your code has an infinite loop, so the first thing that's supposed to be SOP-ed never gets to SOP anything. But Eclipse has a debugger, no? If I had this problem I would step through the code until I reached SOP and then see what happened.
3 weeks ago
Your one question: your field contains a reference to an object. When you copy that to a local variable, you now have another reference to the same object. So copying the reference from the local variable back to the field has no effect. This assumes you're talking about reference variables, by the way. Variables which contain primitive values like int and long, that's different.

As for your other question, you should be asking the person who gave you this advice. It's totally wrong to ask somebody who hasn't even read the actual articles, but has only seen a possibly flawed interpretation of them. Anyway if there is any performance improvement to be had by doing that, it's not the sort of thing that I would spend any time considering. The best performance-improving change I could do to the code I'm working with now would be to buy a faster disk to speed up the database access. (Which I do plan to do.) We're talking about seconds of time reduction there, not nanoseconds.
3 weeks ago