Connecting multiple database using Spring with Bonecp - spring

Am developing an application, where in users has to login to the application by giving username , password and selecting business unit.
Based on business unit, the application has to connect to the respective database. How can this be achieved in spring with bonecp or spring jdbc template ? Considering performance which should I choose spring with bonecp or spring jdbc template

Related

Spring boot oracle database without hibernate?

i managed to connect my spring boot application with postgres without hibernate, but with r2dbc for a reactive application.
I was wondering if i can connect spring boot to oracle database without hibernate for a non reactive application ?
Spring Data provides two basic modules for integrating applications with relational databases. Spring Data JDBC is for imperative applications while Spring Data R2DBC is for reactive ones. They both use the same interfaces and patterns. If you're familiar with Spring Data R2DBC, it will be straightforward to work with Spring Data JDBC.

Runtime database connection using Spring JDBC in Spring boot

I have a requirement wherein a user enters database connection details through a UI, and then from the application I connect to this database, extract the data, and import into my current application.
Users can enter any database connection information, hence these details are dynamic at a user level. I am using Spring boot and Spring JDBC currently, however I was looking for options to connect to other relational databases dynamically during runtime in order to extract data and import to my application database.

is it possible to connect to two databases one with spring jpa and another with spring jdbc

I have a requirement to connect to two databases using spring boot. I can able to connect to two different databases using spring jpa, but I want to connect two databases one with spring jpa and another with spring jdbc
I got the solution. I missed to add ComponentScan for JDBC connection configuration and removed #Primary annotation

Can spring boot applications deployed on a tomcat server use a common connection pooling?

When multiple spring boot applications created and deployed to a tomcat server. Is it possible to use a common connection pooling, datasource instead of providing these details in application.properties file. Or does this already taken care within the spring boot implementation
When you deploy multiple application then each application manages it connection pool.
Spring boot boundary is limited to each application context and it does not know what other application deployed and which db they are using.

Spring-boot JPA connect to postgres where database and schema are provided at runtime

I am building a multi-tenant application, where the tenant database configuration are stored in Redis. Based on the request, I will query the Redis to get the database and schema configured for that tenant, this application is built on spring boot.
I took a look at spring boot's JPA sample, and did some more google to find a suitable solution for this, unfortunately, I couldn't find one.
Is this really possible to use JPA sample provided here ?
https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-data-jpa
Please suggest me any other best possible way to tackle this problem
Thanks
Spring Data JPA uses JPA annotations to define domain model. These JPA entities define schema for your database. Obviously you can't change these entities, nor DB schema on runtime.
So no, updating schema on runtime is not possible with Spring Boot + Spring Data JPA combo.
Database connection (e.g. DB URL, username password) could be more flexible. You would need to create DataSource beans programmatically and somehow programatically define which data source to use for each query per tenant. But this wasn't requirement of Spring nor JPA ecosystem, therefore you may face lot of issues.
I was working on such system before, but we were using plain SQL queries via JDBC and were creating DB connection programatically to achieve schema changes on runtime.

Resources