You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Ci Ci <ve...@e-dba.com> on 2007/08/02 12:13:09 UTC

How to use DataSrouceLoader in a non web application

I am trying to use DataSourceResourceLoader class to load templates form a
database. I've seen How-To on configuring it on a web application. How do
you configure it in a non web based application?

Thanks
Ci Ci
-- 
View this message in context: http://www.nabble.com/How-to-use-DataSrouceLoader-in-a-non-web-application-tf4205261.html#a11961827
Sent from the Velocity - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: How to use DataSrouceLoader in a non web application

Posted by Nathan Bubna <nb...@gmail.com>.
You can manually create an instance of DataSourceResourceLoader, set
the DataSource on it directly using the setDataSource() method, and
then directly inject that instance into your VelocityEngine by doing
something like:

DataSourceResourceLoader dsrl = new DataSourceResourceLoader();
dsrl.setDataSource(myDataSource);

VelocityEngine ve = new VelocityEngine();
ve.setProperty("resource.loader", "data");
ve.setProperty("data.resource.loader.instance", dsrl);
ve.setProperty("data.resource.loader.table", "foo");
... (set keycolumn etc here)

ve.init();

and you should be good to go.

On 8/2/07, Ci Ci <ve...@e-dba.com> wrote:
>
> I am trying to use DataSourceResourceLoader class to load templates form a
> database. I've seen How-To on configuring it on a web application. How do
> you configure it in a non web based application?
>
> Thanks
> Ci Ci
> --
> View this message in context: http://www.nabble.com/How-to-use-DataSrouceLoader-in-a-non-web-application-tf4205261.html#a11961827
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org