When I try to compile your code, I don't get any compiler errors. It seems to me that you're compiling a file which differs from the one you've posted here.
If you use an
IDE for your work, I'd suggest to reformat your code, as it is very unclear in its current form.
Anyway, there are some other issues with your current code:
* You're using generic raw types (eg.
List instead of
List<String>).
This tutorial might help you to use generics better.
* The SQL statement stored in variable
query is syntactically incorrect.
* You're throwing an
Exception. It would be better to throw some more specific exception, for details, see
this.
* In your
catch clause, you're printing the stack trace (which is good), but then allow your code to return the
list.
When an exception happens, the caller of your method won't know about it and will process the returned list as if no error occurred.
You should throw an exception from the inside of your
catch clause. The previous link contains some details on this too.