8

At my work place, we use DAO pattern to hancle any sort of database operation. It hides bulky statements from programmer. Programmers need to write sql query and logic to handle output data. BaseDao handles all sort of operation and return output in required format.

I found that this class is not perfect. I added the code to control number of connections and to handle connection issues like slow connectivity, no connectivty, number of atttempts for connection etc.

But I would have to add more code to support advance feature of JDBC like providing/accessing binary data, Handling resultsets returned from SPs etc.

Is there any Java Framework or group of classes which can cover many of the database operations?

Please suggest.

Jonas
  • 121,568
  • 97
  • 310
  • 388
Amit Kumar Gupta
  • 7,193
  • 12
  • 64
  • 90
  • One more framework in my mind is JOOQ. but unfortunately it doesnt handle SPs output as i mentioned in my question – Amit Kumar Gupta May 12 '11 at 01:40
  • What do you think is missing from jOOQ's handling of stored procedures? Support for result sets returned from SPs? Or is there anything missing in general? – Lukas Eder Jun 04 '11 at 09:11
  • @Lukas, If more than one cursors are being opened in SP... – Amit Kumar Gupta Jun 06 '11 at 00:28
  • I see. That's currently not supported but on the jOOQ roadmap https://sourceforge.net/apps/trac/jooq/ticket/166. Have you found another way of interacting with such stored procedures, e.g. with JPA/Hibernate? – Lukas Eder Jun 06 '11 at 09:15

4 Answers4

5

I think that you are looking for Java Persistence API. It's a Java EE specification and Hibernate is the most popular implementation.

Jonas
  • 121,568
  • 97
  • 310
  • 388
  • Although i found many libraries like jooq,spring DAO(suggested by @qwerty), i think moving to hibernet would a better option. – Amit Kumar Gupta May 07 '11 at 05:08
  • 1
    do you know an example of JPA/Hibernate providing access to results sets returned from stored procedures? Is that easy to achieve from a user perspective? – Lukas Eder Jun 04 '11 at 09:12
3

You could try Spring DAO instead. They have a nice template pattern for handling resultsets.

qwerty
  • 3,801
  • 2
  • 28
  • 43
1

Or you can take another step step back away from JDBC and use Hibernate.

Olaf
  • 6,249
  • 1
  • 19
  • 37
0

Spring Data JPA does even more abstraction than the other suggestions people have made. With that and Hibernate you don't even need to write queries unless it's a complex operation you need to perform.

CorayThan
  • 17,174
  • 28
  • 113
  • 161