A few suggestions:
1. In the code, print the query string and try running that from mysql. If you don't realize the error from doing that:
2. Post the query string
3. Post the error you are getting
4. Post the database table format
5. A guess: strings need to be wrapped in quotes. Numbers do not
I meant adding System.out.println(query) and post the results of that statement. What were the results of my first suggestion? Also, please post the full error that points at the offending line of code.