0

I am preparing the Java 7 certification using one of the mock test suites available.

One of the test questions I stumbled upon is about the JDBC CallableStatement class, and one of the correct answers (according to the tool) is:

A CallableStatement is the only way for a Java program to execute stored procedures in the database if the procedure has in and out parameters.

This seems very presumptuous to me and I was wondering if there are existing libraries out there (maybe proprietary db libraries for instance) which allow running stored procedures without JDBC?

khampson
  • 14,700
  • 4
  • 41
  • 43
NotSoOldNick
  • 555
  • 4
  • 11

2 Answers2

1

I suppose it depends on how nuanced an answer for which they're looking. Since most Java SQL technologies/frameworks depend on JDBC at some level, one could perhaps say that they abstract that away, but it's still technically involved.

However, I could use, for example, MyBatis, to call a stored procedure without ever directly invoking CallableStatement or anything related to JDBC. In that case, I would define a <select> statement in the mapper file which invoked the stored procedure. It could both take arguments and return values.

khampson
  • 14,700
  • 4
  • 41
  • 43
  • 1
    For the actual stored procedure to be executed, a `CallabeStatement` will be used. Even if it is used indirectly, it is still used. – Brett Okken Jul 28 '14 at 02:59
1

MyBatis, Hibernate/JPA and other open source framework all use JDBC under the table.

sendon1982
  • 9,982
  • 61
  • 44
  • So what you and @BrettOkken are really saying is that the statement: "A `CallableStatement` is **the only way** for a Java program to execute stored procedures in the database if the procedure has in and out parameters." is actually and absolutely true, right? – NotSoOldNick Jul 28 '14 at 05:29
  • Yes, that is what I know – sendon1982 Jul 28 '14 at 06:13
  • Well then, I'll eat my hat, not so presumptuous after all :) Thanks for the precision. – NotSoOldNick Jul 28 '14 at 06:16