in this example the result of the first query is that the author value =35216 if this
is place instead of the variable a then it =works so why is wrong with placing a in the
query that stops it working correctly
If I understand you correctly, you expect this line to run a query which will find records where author_id equals to the value stored in local variable a.
It does't work this way. What you need to do is use a PreparedStatement and place a question mark instead of the bits you want to replace with a value. You then use separate method to specify the value of the parameter:
There are still issues to handle: you need to close all resultset, statements and connections in the finally clause (much easier with Java 7 try-with-resources clause), and you should avoid implicit conversions (I'd guess that author_id is an integer, if it is, you should use setInt or setLong, not setString).
I'd suggest reading Oracle's JDBC tutorial, it is a very good resource on JDBC. If there is something unclear in the tutorial, please feel free to ask here.