I'm looking to write a java program that has the following requirements:
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With