I would encourage taking a look at my post in another thread, solving essentially the problem you're describing:
Note that, as @pturmel (correctly) likes to point out, you would not want to do something blocking like system.db.runPrepQuery directly in a frontend call - those scripts block the event dispatch thread, meaning your client will hang up entirely if that query ever returns slowly.