Paul Clapham

Sheriff
+ Follow
since Oct 14, 2005
Paul likes ...
Eclipse IDE Firefox Browser MySQL Database
Vancouver, Canada
Cows and Likes
Cows
Total received
45
In last 30 days
1
Total given
84
Likes
Total received
2283
Received in last 30 days
37
Total given
452
Given in last 30 days
18
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Paul Clapham

Beginning Java forum??? Okay, I respect your feelings so I'll leave it there.

So what I did was, I went into the API and used the "USE" link at the top to find all methods in the standard API which return a LocalTime object. Some of them looked promising but they all ended up with the same error message, no doubt the one you have already seen a thousand times.

And then I was looking through the DateTimeFormatter API to see if I could see a way to sneak in an hour and minute without having to provide anything in the string being passed. Of course there isn't any way, but I saw this in the section about "Resolving":

6. A LocalTime is formed if there is at least an hour-of-day available. This involves providing default values for minute, second and fraction of second.



Which is backwards from what you want, you want to provide default values for hour and minute. So I gave up and produced this sleazy hack which provides an hour-of-day:



It turned out I also had to provide a minute value, otherwise I got the dreaded error message again, but it was already a sleazy hack so, whatever.

Probably when Rob or Stephan show up they will have the non-sleazy-hack version, but at least that's working code.


20 hours ago

Amadeus Pan wrote:I will re-write it.



If I could suggest: You only need to listen to the button, and when it's clicked send the contents of the text fields to the server. Another text field to contain the server's response would probably help.
I have to say, I'm very confused about those listeners.

As I understand it, you have a button which says "Submit" to the user. But clicking on it doesn't submit the question to the server, as I would expect. You also use a MouseListener to listen for clicks on the button, whereas the normal thing to do is to add an ActionListener to the button. I'll assume for now that your method is actually seeing clicks on the button, but you should check that it does.

Then when the Submit button is clicked, you don't send anything to the server. Instead you add some listeners to the TextFields. Yes, I know you said you actually have code to send data to the server, but you said it's in the listeners. So it isn't actually run until the user types something into one of the TextFields. I'm also confused because I don't see where the output of the calculation is supposed to go. And also, this happens every time the Submit button is clicked, so after a while the TextFields could have a large number of listeners attached which all do the same thing.

So the way your GUI works (assuming a lot about the code you accidentally left out) is this: the user clicks on the Submit button. Nothing happens at this point. Then they start typing in the text fields, and every time they type something in one of them, data is sent to the server and the result is, I don't know where it goes. Was it supposed to work that way?
As far as I can see each line in the file is processed exactly once. But something you're looking at persuades you otherwise. Could you tell us what that is?

As for how many ISBN's in the file, which I assume is the same as how many lines in the file, the standard way to count the number of times a loop is repeated is something like this:


1 day ago
No. That statement applies to synchronized methods only, and if you remove the word "synchronized" then it is not a true statement.
1 day ago

Niti Kapoor wrote:like shell script for linux whats is for windows



Batch file.
1 day ago
So, just to clarify that: Did you mean that there was no exception thrown, but the array which was produced by the cast was of length zero?
2 days ago
You could try casting it to a 2-D byte array, like Norm suggested. Would it be difficult to set up a test class to do that?
2 days ago
Imagine two users connecting to your system and executing transactions at about the same time. They are both going to be accessing the database at about the same time, possibly overlapping. That's why you need transactions.
2 days ago
This won't provide you any learning, I don't think. But the hardest-to-debug situation I ever encountered was never solved.

It was one batch of orders which didn't come out right; it looked like one if-statement in one program was always taking the wrong branch and so naturally things didn't come out right. Other batches of orders that night worked fine, the problem had never happened before, and in fact the problem never occurred again. It was a program which we ran for at least 20 years in 20 different warehouses several times every day. There was no reason why that if-statement should have been defective in that one batch of orders. I just happened to be the one in the office that evening, I was working late for some reason, but my main task then was to reconstruct the orders and get them re-entered so the batch could be run again and the orders could go out.

As I said, we never solved the problem. Our best guess was this: You know that the hardware where memory is stored contains error-checking and error-correcting mechanisms, because there's always the possibility that very tiny electrical fluctuations can flip a bit in the memory. So those mechanisms catch and correct something like 99.999999% of those errors. (I don't know how many 9's there actually were in the statistics for our systems.) But not 100%. So there's a tiny, tiny probability that a random error can occur, but if you run your machines for enough years an error will occur. But of course we could never prove that was what actually happened.
2 days ago
Well yes, if you're using schema validation then disabling validation would be a bad idea. But remember that schemas aren't the only way to validate XML. Another validation tool is the DTD, and that's where entities (including external entities) are used. In fact if you read the main OWASP page about XXE processing you'll note that it refers specifically to DTDs and doesn't mention schemas.
You're getting those namespace prefixes because JAXB needs to specify the namespace for those elements. In XML the choice of namespace prefix is completely arbitrary -- it's the namespace URI which matters, not the prefix. Your original document used the default namespace, which is a variation which declares a namespace URI but doesn't use a prefix. Still the same thing as JAXB's output, though. (I dislike the default namespace because it hides from the human reader the fact that a particular element is actually in a namespace, which can lead to confusion.)

Anyway the official position is that namespace prefixes don't matter, so you shouldn't worry about whatever you get from JAXB. However people quite often don't feel that way, they get attached to the prefixes they chose. So if you do a web search for jaxb namespace prefix you'll find a lot of suggestions about how to get JAXB to use your preferred prefix. (I didn't notice if any of the articles covered the default namespace, but then I only did a quick scan.)

ridaen fiefur wrote:however, do you think I need to switch to false the the XML validation content during parse. with isValidating(), for example on SAXParserFactory.
For it doesn't have impact on XXE subject ?



I don't know what you mean to ask here. Originally you were asking about disabling XXE functionality. Now it looks like you're asking about things which aren't related to XXE functionality. I can understand disabling XXE, to avoid various security exploits which are associated with it. But I don't know what security issues would make you turn off validation, or even if there are any, so I have no opinion about whether you should do that or not.
So far you have only created an empty file. But... Carey recommended you could use POI, and you said you wanted to use POI. So it looks like that's settled then. I don't see what's left to be resolved. Go ahead and use POI to write the data into your Excel file.

Of course if you run into problems, the Ranch is here to help.
3 days ago
It seems you think that "remote debugging" can only refer to code running on a different machine. That's not the case. Normally when you debug code in Eclipse, you're debugging code which runs in a JVM which is closely connected to the JVM in which Eclipse is running. Eclipse is written so that it can do that. But apparently, from what you say, Tomcat's JVM isn't connected to Eclipse in that way and hence you have to use a different debugging technique. Which somebody is calling "remote" debugging. This has nothing to do with your idea that it has to be on a different machine.
3 days ago