0

Iam using two data sources in grails application one is local db and the other is remote.

When am running the application if any one of the DB is not accessible then the application is not running .
I don't want this to happen I want to run the application atleast the home page where no database connection is required.

Please help me on this scenario that how to configure my application ..

Srinivas21
  • 63
  • 4
  • Without implementing your own DataSource this isn't going to be possible with a Grails application. If you have a DataSource defined in your Grails application it must be accessible for the application to start up. – Joshua Moore Dec 30 '14 at 11:12
  • thanks for the reply Moore, I am Using two data sources in my application , is it possible to start the application when one of these two data-source's is inaccessible and one is accessible(say local db)?? – Srinivas21 Dec 30 '14 at 12:04
  • No, all defined datasources by default must be accessible for the application to start up. – Joshua Moore Dec 30 '14 at 12:10

1 Answers1

0

Well the straight answer is NO. you can not get your application up unless your datasources have successfully loaded. Whenever there is any problem in making the datsource, an exception is thrown and the execution of the application is stopped, it is assumed that the application may not be able to work properly if there is error in creating datasources.

But you can have a work around by loading the datasources dynamically from the bootstrap. You can follow the link to load hibernate datasource dynamically.

In this case you will not keep the datasource info in the Config but put them in a properties file and load them to load the datasource. You can also keep it in try-catch block to hamndle the exception.

Community
  • 1
  • 1
Ekansh Rastogi
  • 2,418
  • 2
  • 14
  • 23