There are three ways to access the DB:
JQuery gets included at the bottom of the page, so it isn't accessible in your plugins' template. To access JQuery:
You won't have the $() syntax. Use $jq() instead.