Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to write database agnostic/independent code in Java ?

 
David Jason
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each database has its own characteristics and the same SQL statements will not necessarily work on all of them.
In that case, it it seems better to write code for each database instead of one big class that can handle all databases.
Is it possible to make your code database agnostic ? If so, how can we do that ?

 
Dielson Sales
Greenhorn
Posts: 4
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Jason wrote:Is it possible to make your code database agnostic ? If so, how can we do that ?


You can take a look at Hibernate (Java). It can generate the SQL queries depending on the driver used, hence making your code portable to any supported SQL database.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic