Win a copy of Spring in Action (5th edition) this week in the Spring forum!

Paul Clapham

Sheriff
+ Follow
since Oct 14, 2005
Paul likes ...
Eclipse IDE Firefox Browser MySQL Database
Vancouver, Canada
Cows and Likes
Cows
Total received
50
In last 30 days
0
Total given
98
Likes
Total received
2384
Received in last 30 days
4
Total given
525
Given in last 30 days
3
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Clapham

Bob Matthews wrote:and end up with the following integer value variable called Candidate_ID



If "Candidate_ID" is a variable in your Java code then you should change line 1 to a group of lines which use a PreparedStatement.

You already know how to do that because you've done it in lines 6, 8, and 9.
Well, actually the ResultSet is holding a collection of zero or more rows, each of which contains a single column. And that column contains a string (I assume) which is an SQL query.

So the first step is to iterate through the ResultSet and get that string out of each of those rows. I expect you already know how to do that, if not then every tutorial ever written about JDBC will have an example very near the beginning.

And once you have a String value which contains an SQL query... I expect you already know how to create a Statement which uses an SQL query, no?

Hope that helps, if it isn't clear now then ask for clarification about the parts you still don't understand.
If we're going to accept the ideas of Vitruvius on designing and creating a building as a metaphor for designing and creating a software system, then by all means let's go with that metaphor.

Let's suppose you are a building contractor who is responsible for creating a house for a family to live in. Then "commodity, firmness, and delight" -- absolutely. But you are going to hire some people to do the actual construction work, rather than doing it yourself. So, should you know how to use a table saw and a nail gun? Should you know how to install electrical wiring? I would say yes; even if you never pick up a hammer you should still be able to understand what the actual people with hammers are doing and you should be able to talk intelligently about why putting a door in a certain location is a problematic feature of the house's design.

But now let's suppose you are an architect who is responsible for creating a 70-story office building. There's a lot of things which have to happen for the building to be constructed, so you're going to have a team of engineers to make those things happen. They in turn are going to hire crane operators and electricians and heating system designers and accountants and so on and so on... so should the architect be able to, say, make sure that workers are paid correctly and have the correct taxes deducted? Or know how to install a high-rise crane safely?

I'd say no to that. But maybe "Designers Will Code" in the software field should correspond to the idea that architects should be qualified engineers, so that they aren't guilty of designing 70-story buildings which the engineers can't build? It doesn't seem to work that way in the real world, I'm pretty sure that architects don't have to get an engineering qualification before they can start architecting things.

But the article you linked to seems to be talking about small-scale systems, the kind which only have a few people working on them. Those systems correspond to the contractor building a home for a family, so the analogy holds true in that case.

Now let's look at a large-scale system, let's say the system which manages the payroll for the government of Canada. Have a look at Phoenix pay system for some background on that ongoing disaster. In that case the problem wasn't that the designers couldn't code, it was that the designers didn't know how to pay employees. The requirements were more complicated than expected and the designers didn't spend enough time identifying all of the different ways you could be paid if you worked for the Canadian government. Like Corey said, "understand the people who will be using your system". That didn't happen in the Phoenix project.

So yes, for small-scale systems (which is most of them, really) I'd agree that the designer ought to be able to get their hands dirty and do some coding. But for large-scale systems I'd suggest it's more complicated than that.
3 days ago
You print those values before you call the service's shutdown() method, so it's possible that the service hasn't processed all of its executions yet.

At least... I'm answering one question you didn't ask, namely why isn't either of the values 10000000? Another question you didn't ask is why aren't the two values the same, but I chose not to answer that.

It's impossible to answer why the first value is 9947604 and not some other value, for example 9947623. I think you actually asked that question, but it's quite likely you meant to ask one of the other questions which I chose.

Also, if you're asking about a question in a certification exam, please tell us which exam and post the whole question.
The "?>>" characters are a combination of two things:

First, the ? is a type wild-card.

And second, the two > characters are the closing half of the two < characters which come earlier.

So the type expression


breaks down as


4 days ago
It's partly Swing-related; there are two steps in "change keyboard language by using JButton".

The first step is to write code which changes the keyboard language. And the second step is to attach an ActionListener to the JButton which calls the code which was written in the first step.
4 days ago
Welcome to the Ranch, Victor!

Could you be more specific? "Help with this question" doesn't tell us much about your problem.

If you were hoping somebody would post some code for that program, well, the Ranch doesn't work that way. Your homework is your problem. But if you have some code already written, and want to ask a question about that code, then that would be great. Go ahead and post the code and the question.

Or if you're really floundering and have no idea even about how to get started, then go ahead and ask a question like that. Beginners are welcomed here.
5 days ago
Your code is working. Since the letter 'B' comes before the letter 'a' in Unicode, it follows that "Banana" comes before "apple". Have a look at this overly complicated article: Latin script in Unicode and you'll see that 'B' is represented by 66 and 'a' is represented by 97.

But you don't care whether it's "Banana" or "banana", right? You don't care about upper and lower case. So I'd suggest using the toLowerCase() method of String and compare the lower-case versions of the two strings.
6 days ago

Jimmy Robov wrote:In short, Linux usually defaults to using UTF-8 encoding, which is fine for latin scripts, but can't represent Japanese (because 8 bits isn't enough to represent all the characters in the language). The reason you get giberrish, is that at some point when it takes the larger unit data and converts it to UTF-8 (or some other smaller encoding type) automatically, it is simply discarding all the information in the extra bits.



Actually UTF-8 is specifically designed so that it can encode all scripts, including the CJK scripts which Japanese uses. The actual reason that you don't see the correct data is that something is making an incorrect assumption about the encoding being used by the download and hence using the wrong encoding to write the file.

So your code coincidentally happens to work correctly with the Windows server because the DownloadUtils.download() method copies the data in the correct encoding. Possibly that's because the Windows server uses the encoding which you expect the output file to have. My approach would be, for a start, to ensure that the Windows and Unix servers use the same encoding for the download you are using.

I assume that the client code is always running on the same machine, and it's only the servers which run on different operating systems. If the client code works differently on Windows and Unix machines as well, that's another possible source of problems.
6 days ago
Hi Jonathan, welcome to the Ranch!

I've added your post to the forum where JavaScript questions are usually found... if my JS skills were up to date I'd give it a try myself, but there's plenty of other people here with JS skills.
Greenhorn
When you first sign up you are automatically given the rank of greenhorn. You have to earn the title of Ranch Hand!

Ranch Hand
After your 30th post the forum software automatically upgrades your rank to that of Ranch Hand.  This is the last automatic rank change.

Ranch Foreman
Ranch Foremen are recognized as the most productive non-moderator members on Coderanch. At any given time, there may be up to (a total of) seven Ranch Foremen (and Master Ranchers), whom are chosen every month, by Gir Bot -- who is a rather limited, but automated, software bot buried deep within the bowels of the ranch's forum software. Frequently promoted Ranch Foremen are also candidates to be promoted to Bartender by the Trail Boss.

Rancher
On occasion we manually offer members a Rancher title mostly because we feel like it. There is no criteria to this title, it gets applied if and when any staff member feels like it. Benefit to this title is, a rancher gets privilege of granting cow(s).

Master Rancher
Master Ranchers are recognized as the most productive Ranchers on Coderanch. At any given time, there may be up to (a total of) seven Master Ranchers (and Ranch Foremen), whom are chosen every month, by Gir Bot. Frequently promoted Master Ranchers are also candidates to be promoted to Bartender by the Trail Boss.

Author
Authors are folks that have written a book.

 
Bartender
This is the first staff title. Bartenders are people that have been recognized as generous, decent, helpful people and given the keys to a forum to do moderating as they see fit. They can edit, delete, or prune any posts in their forums. If you have a question about a particular forum, you should direct it to (one of) the forum's bartender(s).
 
Saloon Keeper
Saloon Keepers are recognized as the most productive Bartenders on Coderanch. At any given time, there are five Saloon Keepers, whom are chosen every month, by Gir Bot. Frequently promoted Saloon Keepers are also candidates to be promoted to Sheriff by the Trail Boss.
 
Sheriff
Sheriffs are Bartenders (also commonly frequent Saloon Keepers) that have been recognized as being so generous, decent and helpful, that they have been given the keys to all of the forums and most of the rest of Coderanch.
 
Marshal
Marshals are recognized as the most productive Sheriffs on the JavaRanch. At any given time, there are five Marshals, whom are also chosen every month, by Gir Bot.
 
Marshal Commander
The Trail Boss picks one Marshal from time to time as someone who is most likely to be able to jump on issues as they come up.

 
Trail Boss
Paul Wheaton.  'Nuff said.




Some people have donated a big heap to JavaRanch and we let them pick their own custom title.  If you'd like to pick your own custom title, check out the Tip Jar.



Why have greenhorn and ranch hand?

We want strangers to the ranch to feel welcome and the best way to make them feel welcome is to recognize them and say, "Howdy!"  The greenhorn title lets us recognize the new ranch hands.  Greenhorn has nothing to do with Java knowledge.

Why don't you have more automatic titles when a person posts 100 times or 1,000 times?

Now that we've changed to new forum software, we might look at adding some more automatic titles.


CategoryJForum
1 week ago
I'm going to guess that Search_ID is not a column in that database table, and "faltering" means the program crashes because of that error. More information on your problem would be extremely useful.

I see that you are using a PreparedStatement, which is a good first step. But guessing (again) that Search_ID is a variable in your code, or something like that, then the PreparedStatement would look something like this:



Then you would use ps.setInt() to fill in the question mark before executing the SQL.

Hope that helps -- if I'm on the wrong track then by all means help us by providing a full description of the problem.
Welcome to the Ranch, Mike!

The proximate error (the one which makes it hard to see the actual error) is that you don't print a lot of the useful data which the exception includes. Try this instead:



john kaine wrote:so youre saying i can just call the showfavourite method again and if it comes false it wont show the message?



Are you not yet at the point where you could just try that and see what happens?
1 month ago
Here's your original proposed code:



Where you're testing whether the Property in question is a favourite.

But the showFavourite() method you posted -- it does that test too. So you don't have to. Just call the method and let it do its thing.

And I have to say that the comment at the top of the showFavourite() method is absolutely bloody useless. Sure, it happens to be true, but it's still useless. A properly written comment would explain what was in the message and how the Property parameter affects the message. Yes, I know you didn't write that method, I'm just saying that it isn't something you should be learning from.
1 month ago