Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DB Independent Java Programming - Suggestions? [closed]

I'm looking to write a java program that has the following requirements:

  1. An ability to replace the database in use without changes to the code.
  2. I would like to do the maintanence from Java - creating the tables, views etc.
  3. Should be able to support complicated queries

JDBC seems like a good starting point, but it seems like the queries may be different for different DBs (for example slight syntax differences create table statements in MySQL, and MSSQL).

The idea (obviously) is to avoid writing the same code specifically for each DB, and rely on a driver to do the dirty work for me.

Is JDBC good enough? Are there other options?

like image 769
Ariel T Avatar asked Feb 12 '26 09:02

Ariel T


1 Answers

JPA seems to be the optimal choice for you. It works almost-out-of-the-box. Abstracts the direct DB handling away and can be used standalone (without an application server).

JDBC is still a valid option but the development with it is not nearly as DB-agnostic as with JPA (which can be seen as an abstraction layer over JDBC).

Here is a nice example.

Most popular JPA implementations are Hibernate and Eclipselink with Eclipselink (former TopLink) being the reference implementation.

like image 60
kostja Avatar answered Feb 14 '26 21:02

kostja