Create Custom DataSource For Aurora Read Replica

Hi Team

Currently we have our Aurora DB which our CUBA application is connected to its Write Replica

We have created new read replica and we want to to connect our Jasper Report Data Source to be reading from this read replica as we need to split both the datasource of the application from the reporting datasource

We need to implemented something like below

https://www.geeksforgeeks.org/spring-boot-jdbc/

But When I have added the below dependencies it didn’t work I have added the spring boot & spring jdbc starter but still i’m not able to get the below import

org.springframework.boot.jdbc.DataSourceBuilder;

Can you please suggest solution or reference on how to do that ?

Hi Team

Any support please as this is topic

Hi,
CUBA isn’t based on Spring Boot, so you can’t use recipe above.
Generally, you should attach additional data source to a CUBA project as an “additional data store”:
https://doc.cuba-platform.com/manual-7.2/db_connection.html

After configuring, you will be able to obtain DataSource bean instance in the code by its bean name.

Hi @albudarov

Thanks for your response how it will work with the jetty-env file when building our package for the production deployment

Thanks

If you want to define second datasource in the jetty-env.xml file, then it will be published to JNDI.
Use “Obtaining a Data Source from JNDI” section in the documentation link above, how to configure data store for the CUBA app.