1

I need to change Database from MySQL to Oracle.

How can I provide database independency through jdbc without using Hibernate or JPA?

Assafs
  • 3,257
  • 4
  • 26
  • 39
Azim Ahmad
  • 11
  • 1
  • If you don't want to use hibernate, you can use some query builder framework or jooq or activeJdbc Take a look some of them: https://github.com/jkrasnay/sqlbuilder https://www.jooq.org/ http://javalite.io/activejdbc If you want to use only pure jbdc, you have to rewrite your queries. – Emre Savcı Nov 28 '18 at 13:09

1 Answers1

1

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.

Mike
  • 4,722
  • 1
  • 27
  • 40