Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

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

Let me refer you to the article I linked to in an earlier thread. It says:

Doug Bell wrote:The concept of thread safe is simply that the program state (fields/objects/variables) behaves correctly when multiple simultaneous threads are using a resource.

So do you think that the state of the class behaves incorrectly in some way? If so, how?

And then it says:

It's perhaps more useful to look at what it means to not be thread safe. Code is not thread safe when it performs an operation that relies on the underlying state not being changed by another thread without guaranteeing that the state cannot be changed by another thread.

Do you think this is the case with ConcurrentHashMap? If so, why?

Or maybe you disagree with those concepts; they are pretty vague, after all.

Vani Jay wrote:I am referring to a file and not importing.

I don't understand what that means. You use an import statement in Java to tell the compiler that the classpath contains a type (class, interface, enum etc) with that name. If the classpath doesn't, then you get an error message. I don't understand what you mean when you say you're "referring to a file".

but the code I am working from example says like this. So I don't understand where the Import is coming from? Any thoughts?

The import should refer to a Java type which is in your classpath. What you're importing there isn't part of the standard Java API so you'd have to get it from somewhere else. Perhaps there's a jar file somewhere which you were supposed to download?
1 month ago

Vani Jay wrote:import com.actionRegistrationaction;

public static int register(Registrationaction jjform)

If you wanted to import a type named Registrationaction, then you might try changing what you have to import com.action.Registrationaction; instead. (Notice the dot I inserted.) I don't recognize that type but maybe your compiler will, once you get the import correct.
1 month ago
It's impossible for you to get my computer name when I visit your web application. Good thing too.

However... what do you plan to do with my computer name? Perhaps there's some other information you can use which doesn't violate my security?
1 month ago
Likewise if one thread calls the clear() method, then other methods may call the size() method while that clearing is taking place, and may be returned any value between zero and the original size before clear() was called. And this return value will reflect a consistent set of entries at some time. So that's what "thread safety" means in this case; as Stephan said, it isn't the same as synchronization.

Caused by: Connection timed out: connect

This error message suggests that the database server is running, but that it does not respond to your connection request for a very long time. You could check with the person responsible for the database to find out what's going on.
Hi jaedon, welcome to the Ranch!

You're right that it's simple (or fairly simple, anyway). So let's start: what part of the code do you think is calculating the highest value? You'd need to change that code to calculate the lowest value.
1 month ago

java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection`enter code here

That bold-faced part is from your code, isn't it? Was it supposed to be replaced by the actual connection information?
Thanks Stanley, and welcome to the Ranch, both of you!

Ralf Coby wrote:Yeah, that's what i wanna want to do.
The problem is, that my cipher-bytearray only accepts 128 fields.
So, I first tried to save the "128 fields" in an Arraylist, which should be one package.
Like: b.get(0) is equals to byte[128].

It would help if we knew what you meant by a "field" and a "package".
1 month ago
Because you can implement more than one interface, whereas you can't extend more than one abstract class.

Mo Alexwainy wrote:Also, the below js runs anytime in my servlet whenever i execute it. It does not run at anytime later on.

out.println("<script type=\"text/javascript\">");
out.println("document.getElementById('myBody').innerHTML = '';");

No, it doesn't. The Java code which you posted there of course runs every time you execute the servlet. It generates that JavaScript code and sends it as part of the response.
That format is totally irrelevant to your question. It's just how the JTable chooses to display your date. That is... provided you actually put Date objects into the table, and not formatted Strings which represent dates.
1 month ago
And in your previous thread you said you were compiling this with Java 8, but then you said something about Java 7. So make sure you're compiling with Java 8.
1 month ago

omar tawfeek wrote:can you give me an example how to get difference between date using Jdatechooser , when i always subtract date 2 to date 1 , i always get an error saying date cannot be converted to int .

No. You wouldn't use a JDateChooser to get the difference between two Date objects.

You know that a Date object doesn't represent a Date, right? It represents a particular instant of time, to the nearest millisecond. So again, you'll have to decide what you mean by the difference between two Date objects. The number of milliseconds between those two instants of time? Or perhaps the number of days which those milliseconds make up? If you don't want to deal with all those annoying details and you just want to deal with days, then, again, I suggest you use a LocalDate from the java.time package.

also can JTable1.getValueAt method get the date format from table or it can only get number values ?

The getValueAt() method returns an Object, namely the object which is stored at that position in the table's data model. If you put a Date into the data model then you can cast the result of getValueAt() to Date, but if you put some other thing derived from the Date into the data model then you can only get that other thing out.

I don't understand what you mean by "date format".
1 month ago