Home > OS >  How to implement configuration to use oracle/postgreSQL dataSource with spring mybatis framework?
How to implement configuration to use oracle/postgreSQL dataSource with spring mybatis framework?

Time:02-18

Background: spring mybatis oracle data source

Requirement: support postgreSQL data source exchange with minimum code change

Example:

Current: controllerA -> ServiceA -> daoA -> A.xml (oracle)

Now need: we can configure use oracele/postgreSQL database source

If configure use postgreSQL: controllerA -> ServiceA -> daoA -> A.xml (postgreSQL)

More:

Same controllerA、ServiceA for same business logic

Differenct DaoA、A.xml for oracle and postgreSQL mybatis sql implementation

DaoA is better to be same if it can be.

The data and sql logic is the same for oracle and postgreSQL, just need a congfiguration to change to use oracle/postgreSQL implementation.

How to implement it?

CodePudding user response:

Solution is on the comments: use databaseIdProvider technique will work

  • Related