Justin Chu

Ranch Hand
+ Follow
since Apr 19, 2002
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 Justin Chu

I'm writing a program that is executed by cron throughout the day.

It has to use a RSA identity file to connect to another server (using jcraft's jsch). If I perform the procedure by hand on the command line, it involves entering a passphrase to decrypt the private key.

What is a secure solution that does not involve coding the passphrase somewhere in the code?

An idea I have is just to store the identity file unencrypted, and make sure that the file has its permission set securely.
15 years ago
What's a correct way to maintain a cache of objects queried from the database and make it available to remote clients through a SLSB?

Seems like it is very difficult to achieve this without violating EJB rules against managing threads and static variables (or by using singleton). In order to have objects shared by threads, they have to be stored in some static scope, and synchronization is a must.
[ December 10, 2008: Message edited by: Justin Chu ]
I'm encountering a dead lock situation (infrequent) that is narrowed down to the following scenario.

One regular sql statement is calling the following, deleting possibly thousands of rows

"delete mytable where date = ?"

At the same time, a second job is calling the following sql using batched execution

"delete mytable where date = ? and username =?"

For both calls, autoCommit is not set to FALSE. (true by default)

My suspicion is that executeBatch() in the 2nd sql is somehow allocating more than one sql statement to a transaction. If this is the case, is this a JDBC spec behavior? Or is this oracle jdbc driver implementation bug?
[ August 12, 2008: Message edited by: Justin Chu ]
I'm not exactly sure where to post this question, and I thought to start here since it is most related to SQL.

Are there any open source projects out there that allows one to host parameterized SQL queries on a J2EE server? A remote user can select from the list of queries hosted on the server, build parameters, validate and send a request to the server for execution. The server will execute the query and return the dataset to the remote client. (Swing based preferred)

Can anyone suggest Wikis or online documentation on how to setup log4j socket appending?

I've seen SocketHubAppender javadoc description, it is what I'm interested in, however I didn't find instructions on setting up the hub server and have chainsaw setup as listener.


I'm getting generic array creation error on #1.
What's the reason behind this error? What violation can happen if this is allowed?
16 years ago
I'm trying to solve a problem of creating block-like adjustments along a line on a graph defined by points. There is an existing routine that will move points within a given range. In order to simulate the block shifts,
one way to solve it is to insert interpolated points just around the boundaries before calling the point shifting routine.
16 years ago
Given a primitive double d, how to find the absolute largest double that is less than d?
16 years ago
If Timer is built into a framework that allows user to add listener and to turn it on/off. It just makes it unpredictable from the developer perspective.

I've looked into Timer's source code, it seems that it is guaranteed.

Even if an event is queued in EDT, prior to firing it always check against a notify boolean.
16 years ago
For instance, I added a job to the timer to blink some button. Now that I want to remove that button, I'd naturally do timer.stop() and then nullify the button.

If calling stop() in the EDT doesn't prevent any event to be enqueued to the EDT, the late action can cause NPE. Of course, this can be solve easily by having more rigorous checking.
16 years ago
It is technically not about thread safeness of Timer class, but I'm concern about possibility of ActionListener event being fired after timer.stop() is called in the EDT.

Consider the following case:
// at about the same split second where event is to be fired...
// action listeners get fired off

Is it possible to have the above scenario happen?
16 years ago
Use the following construct, not too complicated, and you get all the optimization. "n" is scoped in the for block, so it disappears with i.

16 years ago
Most likely, the states of your actions are based on some "model", have your actions register listeners to the model.

So, when the model is changed, all actions are notified through the listeners. Make sure the notification is done in event dispatcher thread.
[ November 01, 2007: Message edited by: Chu Tan ]
16 years ago
A thread, T1, is able to "interrupt" another thread, T2, by calling the interrupt() method on T2's thread object. Interruption can lead to different scenarios depending on the state of T2 while being interrupted.

Read the javadoc for what interrupt does

If you want to interrupt a thread, make sure the thread knows how to handle interruption correctly.
Thanks, I figure that it wouldn't be an issue 99% of the time for finding mean.

How about calculating variance? It requires sum of squares that can overflow if trying to find the variance of 1000000 data points?

I've found wikipedia's http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance . Are there any open source packages that will solve such problem?
16 years ago