Mahout has an "in-memory" recommender that has a java API. You feed it your preferences data then query it for recs by user id. No database required. It is limited by the size of your training data though. If the data is too large, you have to go the hadoop/db route.
check out the in-memory item and user based recommenders here: https://github.com/apache/mahout/tree/trunk/mrlegacy/src/main/java/org/apache/mahout/cf/taste/recommender
There is a new experimental version in the examples folder of Mahout 1.0-SNAPSHOT that is meant to be integrated with Solr. It prepares data that can be queried using Solr.