Page 1 of 1
enthuware.ocpjp.v7.2.1351
Posted: Sun Dec 22, 2013 12:32 am
by santhoshpr4
Answer for this should be 'It will not compile'.
Connection c = DriverManager.getConnection("jdbc:derby://localhost:1527/sample", "app", "app");
This line will throw SQL Exception and this not handled in the code, this code is placed before the try catch.
is it correct ?
Re: enthuware.ocpjp.v7.2.1351
Posted: Sun Dec 22, 2013 5:41 am
by admin
Since this is a partial code listing, you can assume that the code is placed in a method that has appropriate throws clause. That is why there is a statement in the question:
(Assume that items not specified such as import statements and try/catch block are all valid.)
HTH,
Paul.
Re: enthuware.ocpjp.v7.2.1351
Posted: Sun Aug 07, 2016 3:59 pm
by insider
Typo: "It moves the cursur"
Re: enthuware.ocpjp.v7.2.1351
Posted: Thu Aug 31, 2017 7:31 am
by horst1a
What if the first column in STUDENT were a double ? Should it not throw an Exception?
Shoud it not better say rs.getObject();
Best regards
Re: enthuware.ocpjp.v7.2.1351
Posted: Thu Aug 31, 2017 8:41 am
by admin
No, even for double then it will not throw an exception. But you have a point. As per Appendix B of JDBC specification, getString will work for all data types except CLOB, BLOB, ARRAY, REF, STRUCT, JAVA_OBJECT, ROWID, NCLOB, and SQLXML.
For the purpose of exam, however, you can assume that getString will work for all.
HTH,
Paul.
Re: enthuware.ocpjp.v7.2.1351
Posted: Fri May 29, 2020 3:26 pm
by saurabh.agarwal560
It will not compile because of try with resource block is not defined properly. There should be no semicolon. Please clarify.
Re: enthuware.ocpjp.v7.2.1351
Posted: Fri May 29, 2020 10:25 pm
by admin
Did you try compiling it?