I finally found the cause... I was my careless mistakes!
The statement
String query = "select count(userID) as count" +
"from ServiceUsers " +
"where username=\'" + username + "\';";
should be
String query = "select count(userID) as count " +
"from ServiceUsers " +
"where username=\'" + username + "\'";
Take a look at the end of first line, there should be a space! And I found that I must not put the semi-colon after SQL statement, otherwise exception will be thrown.
Thank you Mujahid Mohamed.
[Message sent by forum member 'graphitecube' (graphitecube)]
http://forums.java.net/jive/thread.jspa?messageID=339446