« Return to Thread: JNDI connection pooling issues

Re: Environment datasource details from service

by Jeff Brown-16 :: Rate this Message:

Reply to Author | View in Thread

On Thu, May 1, 2008 at 4:58 PM, Ladislav Skokan <lsk@...> wrote:
> Hello,
>
>  any idea  how can I access datasource details from a service? I want to
> copy data from Grails database to an another one inside a service.
>
>  Thank you, Ladislav.
>

If you declare a property in your service called "dataSource", Grails
will inject an initialized DataSource for you...

class FooService {
    def dataSource

    def doSomething() {
        def conn = dataSource.connection
        // ...
    }
}

I hope that helps.



jb
--
Jeff Brown
Director North American Operations
G2One Inc.
http://www.g2one.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: JNDI connection pooling issues