matcauthon
matcauthon

Reputation: 2261

Grails Change Datasource (JDBC URL) at runtime

I want to change my default (and only) datasource (jdbc url, username, password) in a view. These changes should immediatly affect the connections.

There are currently no answers that fit my needs.

I'm stuck using this in my controller:

dataSourceUnproxied.with {
  url = params.jdbc
  username = params.user
  password = params.password
}

But the connections are still pointing to the old datasource.

How can I reset the current data source and use the new properties (using Grails 1.3.7)?

Upvotes: 1

Views: 1808

Answers (1)

AA.
AA.

Reputation: 4606

You can to use the datasource plugin to create a new datasource for that view and change it dynamically if you need. Check it: grails how to get data from another data base in runtime

Upvotes: 1

Related Questions