Multiple db connection pools in spring boot application

I am trying to figure out how to handle perseverance inside my application. I am using spring boot.

I have a case where I run under tomcat using connection pools that are defined in server.xml through ResourceLink from my context.xml applications. They DO NOT need to be defined this way, but they must be pools, and they must be customizable outside the application. I have 2 databases that are Oracle. I need to be able to connect to each of them and run queries.

So imagine what I like

public class Person {
    private String name;
    private int age;

    public Person() {}
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
    // getters and setters
}

I need to configure 2 "pools" or something similar so that I can do something like:

List<Person> p1 = PersonDAO.getAllPersons(pool1); // get all people from first database
List<Person> p2 = PersonDAO.getAllPersons(pool2); // get all people from second database

Something along these lines ... How / where can I configure pools? And what does the DAO look like?

edit: "duplicate" (Spring ) , , , , , .

0

Source: https://habr.com/ru/post/1684448/


All Articles