« Return to Thread: JNDI connection pooling issues

Re: Environment datasource details from service

by Ladislav Skokan :: Rate this Message:

Reply to Author | View in Thread

Jeff,

if does not seems to work. the "dataSource" is always null.

L.

Jeff Brown napsal(a):
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
  

--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

 « Return to Thread: JNDI connection pooling issues