I need to change Database from MySQL to Oracle.
How can I provide database independency through jdbc without using Hibernate or JPA?
I need to change Database from MySQL to Oracle.
How can I provide database independency through jdbc without using Hibernate or JPA?
You can always just use the JDBC API: Connection
, PreparedStatement
, ResultSet
, etc:
https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html
Every JDBC compliant database driver has to implement these interfaces so you can somewhat easily switch between drivers. Just bear in mind every DB server has their own nuances and features that aren't part of standard SQL, so not all queries will be independent.
If your app is already using Spring, then consider using Spring Data:
https://spring.io/guides/gs/relational-data-access/
They provide lots of abstractions and features that make working with SQL a little easier than the pure JDBC API.