Developer's Note

// shall I write some keywords here to boost search engine ranking?

Monday, June 15, 2009

ERROR 1 (HY000) at line 1: Can't create/write to file

MySQL SELECT statement allowed us to pipe the query result in to a file via SELECT ... INTO OUTFILE. It work just fine for me most of the time, until recently I hit this error:

ERROR 1 (HY000) at line 1: Can't create/write to file '\home\myuser\my_output_file.txt' (Errcode: 2) mv: cannot stat `/home/myuser/my_output_file.txt': No such file or directory
The first thing come to my mind is the problem of file permission, so I grant 777 permission to my output directory. But the problem still exist.

Then I check the Mysql username I use, and found that it was granted with FILE permission correctly.

Then I start to google on this error code, and most of the search result point to similars causes.

So I read again the documentation of MySQL, and I found this:
The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected rows to a file. The file is created on the server host, so you must have the FILE privilege to use this syntax.
And the keyword is "server host". I made wrong assumption that it will write file to the server that execute the SELECT ... INTO OUTFILE.

And the workaround is simple, just change my SELECT statement by remove the OUTFILE portion. And pipe the query to file from the MySQL command line
mysql -u myuser -ppassword -h remotehost mydb < myquery.sql > my_output_file.txt
Reading documentation is bored but important :P

Sunday, April 19, 2009

Passwordless SSH login via Public Key Authentication

SSH login with password authentication is often a problem for shell script that run without human interaction. One of the option by simulating user input via some Expect script. While another option is to setup certification based authentication.

Below is the steps:

1. SSH to client host (said with username 'myuser')
2. Generate keys at client host, press 'Enter' while it prompt for key location and passphrase.:


$ ssh-keygen -t rsa

3. Upload the public key generated (~/.ssh/id_rsa.pub) to remote host home directory (said username 'remoteuser')
3. SSH to the remote host with same username ('remoteuser'), create the .ssh folder if not exist

$ cd ~
$ mkdir .ssh
$ chmod 700 .ssh

4. Import public key into authorized_keys

$ cat id_rsa.pub >> ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/*


Now when the 'myuser' at client host SSH to remote host with username 'remoteuser', it will not prompt for password anymore.

Thursday, March 05, 2009

Duplicate log in log4j

If you have log4j configured as below, you will notice that log entry from "yourLogger" will duplicate in appender


log4j.rootLogger=info, stdout
log4j.logger.yourLogger=info, stdout


To solve this, just change your configuration to:


log4j.rootLogger=info, stdout
log4j.logger.yourLogger=info, stdout
log4j.additivity.yourLogger=false

Thursday, January 01, 2009

Reading List: Dec 2008 Wrapup

IO performance - Tar vs. File vs. Byte streams
Benchmark that show TAR file processing as a good alternative for better performance.

Google Has Open-Sourced Their C++ Mocking Framework

Top Java Developers Offer Advice to Students
11 Top Java developers sharing their experience.

Saturday, December 27, 2008

Axis2 WSDL2Java error for SOAP Encoding

Recently had hit the SchemaCompilationException when using Axis2 wsdl2java to generate client stub from a WSDL file.

After some google, had found this page is describe same problem as what I face. And the reason for the exception is due to Axis2 do not support SOAP Encoding.

Fortunately after a while, my colleague had found the solution. Instead of using ADB for data binding, use XMLBeans. Below is example of the command:

wsdl2java -uri myService.wsdl -d xmlbeans