Re: About Question enthuware.ocpjp.v11.-2-.3667 :

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

Moderator: admin

Post Reply
bdshadow
Posts: 3
Joined: Fri Jul 04, 2014 7:46 am
Contact:

Re: About Question enthuware.ocpjp.v11.-2-.3667 :

Post by bdshadow »

could you, please add an explanation why the second option is incorrect:

ps.setNull(3, JDBCType.INTEGER);
ps.setNull(4, JDBCType.VARCHAR);

i didn't get from other explanations why it is wrong

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

Re: About Question enthuware.ocpjp.v11.2.3667 :

Post by admin »

It is wrong for the exact same reason option 1 is wrong. Already explained in detail:
The second parameter to the setNull method is of type int and it expects the value to be one of the constants defined in java.sql.Types class. Among other constants, it has INTEGER and VARCHAR for int and String values respectively. STRING is not a valid constant in this class.

java.sql.JDBCType also defines the same names (i.e. INTEGER and VARCHAR, among others) but it is an enum.
If you like our products and services, please help us by posting your review here.

bdshadow
Posts: 3
Joined: Fri Jul 04, 2014 7:46 am
Contact:

Re: About Question enthuware.ocpjp.v11.2.3667 :

Post by bdshadow »

The first option is wrong, because it has "ps.setNull(4, JDBCType.STRING);", where JDBCType.STRING is not a valid constant.

Also the first option is different from the 2nd in only one line, which is "ps.setNull(4, JDBCType.VARCHAR);" in the second line. And it is correct. JDBCType has VARCHAR as value. So why it is wrong?

Sorry if i'm missing smth

bdshadow
Posts: 3
Joined: Fri Jul 04, 2014 7:46 am
Contact:

Re: About Question enthuware.ocpjp.v11.2.3667 :

Post by bdshadow »

sorry, i got it. The type itself is incorrect. It must be java.sql.Types class

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests