• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sybex CSG 11 - Chapter 21 JDBC - Question 20

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


A. The stored procedure can declare an IN or INOUT parameter.
B. The stored procedure can declare an INOUT or OUT parameter.
C. The stored procedure must declare an IN parameter.
D. The stored procedure must declare an INOUT parameter.
E. The stored procedure must declare an OUT parameter.


Since the code calls registerOutParameter(), we know the stored procedure cannot use an IN parameter. Further, there is no setInt(), so it cannot be an INOUT parameter either. Therefore, the stored procedure must use an OUT parameter, making option E the answer.

----

My question is: the sql is {call transform(?)}, which has an input parameter. The provided code doesn't set a value for the input parameter. What happens at runtime if stored procedure declare OUT parameter?

I think, the correct answer must be: "The stored procedure must declare an INOUT parameter and cs.setString(1, "a value") must be added before cs.execute() statement".
Or maybe the question must be corrected with var sql = "{call transform()}";
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Annoyingly different databases have different syntax and rules for the ? in a stored procedure. This means for the exam you have to answer based on the JDBC API calls and not infer based on the call command in the string.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic