How can the sql statements in Java projects be compatible with multiple databases? The project belongs to the product category and it is not confirmed which database the user uses. We use db2 during development, but if we encounter an oracle database, sql will fail. I don't know how to achieve compatibility with multiple databases. For example, oracle, MySQL, SQL server, db2, etc.
You can try using an ORM framework that supports multiple dialects.
Isn’t ORM the solution to this problem? It executes different sql, jpa, hibernate according to the configured database dialect