enthuware.ocpjp.v7.2.1351
Moderator: admin
-
- Posts: 1
- Joined: Sun Dec 22, 2013 12:17 am
- Contact:
enthuware.ocpjp.v7.2.1351
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 ?
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 ?
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: enthuware.ocpjp.v7.2.1351
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.
(Assume that items not specified such as import statements and try/catch block are all valid.)
HTH,
Paul.
-
- Posts: 29
- Joined: Wed Apr 17, 2013 9:22 am
- Contact:
Re: enthuware.ocpjp.v7.2.1351
Typo: "It moves the cursur"
-
- Posts: 37
- Joined: Mon Jun 12, 2017 2:16 am
- Contact:
Re: enthuware.ocpjp.v7.2.1351
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
Shoud it not better say rs.getObject();
Best regards
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: enthuware.ocpjp.v7.2.1351
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.
For the purpose of exam, however, you can assume that getString will work for all.
HTH,
Paul.
-
- Posts: 11
- Joined: Thu May 28, 2020 9:53 am
- Contact:
Re: enthuware.ocpjp.v7.2.1351
It will not compile because of try with resource block is not defined properly. There should be no semicolon. Please clarify.
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: enthuware.ocpjp.v7.2.1351
Did you try compiling it?
Who is online
Users browsing this forum: No registered users and 23 guests