Quantcast

Getting to the db connection inside Controller

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Getting to the db connection inside Controller

a.shneyderman
I have a requirement, that needs to digress a bit from the
model/view/controller architecture or I should say I only need view
and controller portions of grail. In my controller I need to get a
reference to the datasource and run a query against it. How does one
get a reference to a connection in  the pool?

--
Thanks,
Alex
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Getting to the db connection inside Controller

graemer
You should be able to get a reference to the DataSource instance
through dependency injection by having a property like:

@Property DataSource dataSource

Graeme

On 4/13/06, Alex Shneyderman <[hidden email]> wrote:

> I have a requirement, that needs to digress a bit from the
> model/view/controller architecture or I should say I only need view
> and controller portions of grail. In my controller I need to get a
> reference to the datasource and run a query against it. How does one
> get a reference to a connection in  the pool?
>
> --
> Thanks,
> Alex
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Getting to the db connection inside Controller

a.shneyderman
I tried to create a spring/resource.xml bean and wire dataSource to
it, and it did not work.
I guess it should work if I create a service and wire service into the
controller.

Thanks,
Alex.
Loading...