Reputation: 69
I need to make a REST API so two components can communicate with each other.
The flow starts like this:
How do I make this appen in Spring Boot? I don't need any domain class, so I don't think I need to use JPA.
Update: I need to make it work with JdbcTemplate
Thanks in advance
Upvotes: 1
Views: 1019
Reputation: 123
I'm not sure what you intend to achieve here but this is what I would suggest you do if you really need to achieve this with JDBC template.
application.properties
, you could specify keys to hold values used in configuring every different connection to the databases you need to interact with. A naive example could be:app.datasource1.url=...
app.datasource1.driver=...
app.datasource1.username=...
app.datasource1.password=...
app.datasource2.url=...
app.datasource2.driver=...
app.datasource2.username=...
app.datasource2.password=...
You could create beans of these connections in a config class and differentiate them with names (qualifiers)
, one of them could be a tagged primary data source and the other a secondary data source. As an alternative, however, you can do 3 each time you need an instance of the DB connection.
Since you are using the JDBC template, in the service classes or implementations where you make calls to the database, you could start first by creating a connection (an instance of JDBC Template)
before using it.
With this approach, you can create as many connections as you want to as many DB as you want. Don't know if this helps.
Upvotes: 1