About Question enthuware.ocpjp.v7.2.1370 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
Venceslas
Posts: 15
Joined: Thu Feb 05, 2015 3:50 pm
Contact:

About Question enthuware.ocpjp.v7.2.1370 :

Post by Venceslas »

Hello,

Why the last answer add these words at end of the sentence please:
"if the procedure has in and out parameters"

Regards,
Chris

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1370 :

Post by admin »

Because if a procedure does not have any out parameter, you can use a simple Statement or a PreparedStatement as well.
If you like our products and services, please help us by posting your review here.

Venceslas
Posts: 15
Joined: Thu Feb 05, 2015 3:50 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1370 :

Post by Venceslas »

Ok, thank you.

UncleF
Posts: 11
Joined: Wed Jun 14, 2017 3:43 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1370 :

Post by UncleF »

I think this question is trying to illustrate the case when the same parameter used as IN is also used as OUT in CallableStatement.
Am I right?
Because in all other cases you can use Statement and PreparedStatement for the same task. Yes, CallableStatement adds some syntactic sugar to it, but it's totally possible to execute a stored procedure, pass parameters to it and receive results without CallableStatement.
So, if I'm right then the last option has to be changed to "if procedure has IN/OUT parameters"
Or maybe change "is the only way" to "is the recommended way" or "best way".
Otherwise, It's just plain wrong.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1370 :

Post by admin »

Yes, and that is what it says as well, at least since 06.28.2015 (exactly 2 yrs ago!) when it was last updated.
test.png
test.png (23.77 KiB) Viewed 6217 times
If you like our products and services, please help us by posting your review here.

UncleF
Posts: 11
Joined: Wed Jun 14, 2017 3:43 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1370 :

Post by UncleF »

So you think the 4-th option is making clear that it's describing the situation with parameters which could be used for both IN and OUT? I mean the same parameter used for IN and OUT.
Because I see it differently.
Anyway, English is not my native language so maybe it's some special language form which I don't understand correctly.
From my point of view it's just saying "stored procedure receiving some parameters and returning some parameters".

I'm talking about this case:
CallableStatement call = conn.prepareCall(
"{CALL doubleMyInt(?)}");
// for inout parameters, it is good practice to
// register the outparameter before setting the input value
call.registerOutParameter(1, Types.INTEGER);
call.setInt(1,10);
call.execute();
int retval = call.getInt(1);

Here we have only one parameter which we use for both passing value to stored procedure and receiving some value back. In all sources, it's called inout or INOUT parameter not "in and out".

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1370 :

Post by admin »

May be I didn't get your point. Let us say you have a stored proc that has in as well as out parameters (forget abt inout for now). How will you use a Statement or a PreparedStatement to call it? The registerOutParameter method is there only in CallableStatement.
If you like our products and services, please help us by posting your review here.

UncleF
Posts: 11
Joined: Wed Jun 14, 2017 3:43 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1370 :

Post by UncleF »

ResultSet?
Can't I use this to get results of execution of stored proc?

I think I got your point.
We can get data from stored proc using Statement and PreparedStatement but we can't designate this data as a parameter. To designate it as 'out' parameter we need CallableStatement.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 49 guests