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

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

Related

Spring Cassandra repository with manual connection

I want to use spring data Cassandra but I don't want use spring boot configured connection. I will create a connection which has to be used by Cassandra repository. Is this possible

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.

Is it possible to connect DB in Spring Boot and Spring Data JPA without third party JPA provider

I need to connect a Oracle 12c DB and query a table and fetch the results.I am using Spring Boot 1.2.4.Now if I use Spring Data Jpa will it suffice this requirement or Do I need to use JPA provider like Hibernate or Open JPA is a must along with Spring Data JPA.
Is there any examples which use only Spring Data JPA without any third party JPA provider?

Connecting Spring to Existing JDBC Connection

I've followed this tutorial through Spring's docs. It's nice, but I can not find anything online (and current) that shows how to connect to an existing DataSource through JDBC using Spring. Where can I configure this connection? This tutorial only shows how to create one (but where exactly is it even doing that?).
From your how-to link, you can see:
Spring Boot spots H2, an in-memory relational database engine,
and automatically creates a connection. Because we are using
spring-jdbc, Spring Boot automatically creates a JdbcTemplate.
The #Autowired JdbcTemplate field automatically loads it and
makes it available.
You can bypass the default DataSource by adding #EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}) to your Application class. This link provides more detail on setting up a DataSource in Spring Boot.
...and the other sections are pretty useful too!
You are using Spring boot which contains embedded databases, in this case H2 database (check line "Spring Boot spots H2, an in-memory relational database engine, and automatically creates a connection.")
To provide custom connection and configure DataSource see this section https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-sql.html

Spring boot application having second datasource failing caching

The presence of a second datasource in a spring boot application is failing caching with the exception:
java.lang.IllegalArgumentException: Cannot find cache named 'entity-name' for CacheEvictOperation
With one datasource it's working.
Both the datasource is auto-configured by spring boot.
Datasource one using mysql, declared as primary
Datasource two using mongodb
Is this a known case? Do I need to explicitly configure entity and transaction managers?
Spring Boot does not support auto-configuring more than one datasources for general purposes so you may want to revisit your configuration (or the description).
Yes, you need to configure the entity manager and transaction managers explicitly when you need to use more than one datasource.
Hopefully, this sample shows you how to do it.

Resources