Like Shikhar Madhok has already said, its probably nothing to do with the query itself. If it runs quickly in another SQL client, you can assume its OK. You can further verify this by running an explain plan on the query.
Is Statement better than Prepared Statement?
Potentially yes. But this change is unlikely to improve a query that takes 20 minutes to run. 20 minutes is a massive amount of time for a query to take, unless the application is some sort of bulk import/export tool.
Likely issues could be:
very large result sets. Your Java app might be running out of memorynetwork latency. This will be more pronounced if the result set is big, since there is more data to pull over the network. Large data types will also slow this down (e.g. image data types)blocking caused by some other operation in your Java application. It could just be that other JDBC operations you perform adversely affects the queryComplex logic being performed while iterating though the result set. Can you post your code?