Thursday, April 17, 2014

How to enable MySQL query monitoring

Do you need to monitor any SQL statements passing through your MySQL server? You would need to turn on the server logging. Edit your my.cnf file and add these:


You also need to restart the database server after these changes.

Wednesday, April 16, 2014

Be careful with Java Path.endsWith(String) usage

If you need to compare the object, be aware that Path.endsWith(String) will ONLY match another sub-element of Path object in your original path, not the path name string portion! If you want to match the string name portion, you would need to call the Path.toString() first. For example

// Match all jar files.
Files.walk(dir).forEach(path -> {
if (path.toString().endsWith(".jar"))

With out the "toString()" you will spend many fruitless hours wonder why your program didn't work.

Monday, April 14, 2014

How to disable MySQL case sensitive with table names in queries

My latest install of MySQL 5.16 on Windows 7 is case sensitive with table names. I much prefer it's case in-sensitive for faster typing and adhoc queries. To do that, I need to edit the my.cnf file (Try running "mysql --help" and it will tell you where it is.)

At the end of the file, add this line:

lower_case_table_names = 1

Tuesday, April 8, 2014

How to setup remote debug with WebLogic Server and Eclipse

Here is how I enable remote debugging with WebLogic Server (11g) and Eclipse IDE. (Actually the java option is for any JVM, just the instruction here is WLS specific.)

1. Edit <my_domain>/bin/ file and add this on top:

JAVA_OPTIONS="$JAVA_OPTIONS -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"

The suspend=y will start your server and wait for you to connect with IDE before continue. If you don't want this, then set to suspend=n instead.

2. Start/restart your WLS with <my_domain>/bin/

3. Once WLS is running, you may connect to it using Eclipse IDE. Go to Menu: Run > Debug Configuration ... > Remote Java Application and create a new entry. Ensure your port number is matching to what you used above.

Read more java debugging option here:

Saturday, April 5, 2014

Creating your own loop structure in Java 8 lambda

Java doesn't have an easy construct of repeat something N number of times. We can make a for loop of course, but many times we don't even care about the variable that we created in the loop. We just want repeat N times of some code and that's it. With the lambda available in Java 8, you may attempt something like this:

public class RepeatDemo {
    public static void main(String[] args) {

        // One liner repeat
        repeat(10, () -> System.out.println("HELLO"));

        // Multi-liners repeat

        repeat(10, () -> {
    static void repeat(int n, Runnable r) {
        for (int i = 0; i < n; i++)

Probably not as eye pleasing or straight forward as the good fashion for-loop, but you do get rid of the unnecessary loop variable. Only if Java 8 would go extra mile and treat the lambda argument in method with sugar syntax, then we could have it something like the Scala/Groovy style, which makes code more smoother. For example:

        // Wouldn't this be nice to have in Java?

        repeat(10) {


Thursday, April 3, 2014

How to reset WebLogic admin server password

If you forgot your admin user password for WebLogic, you can reset it this way. Ensure you are in the domain directory first! 
source $WL_HOME/server/bin/ 
cd mydomain
mv security/DefaultAuthenticatorInit.ldift security/DefaultAuthenticatorInit.ldift.bak
java <admin_username> <new_password> security