Oracle
1Z0-860 · Question #245
Given the following code in an EJB 3.0 session bean: 10. @Resource(name="jdbc/employeeDB") 11. private DataSource dataSource; 12. 13. public void lookupEmployee(String id) { 14. InitialContext ic =…
The correct answer is E. Object obj = ic.lookup("java:comp/env/jdbc/employeeDB"). See the full explanation below for the reasoning.
Question
Given the following code in an EJB 3.0 session bean: 10. @Resource(name="jdbc/employeeDB") 11. private DataSource dataSource; 12. 13. public void lookupEmployee(String id) { 14. InitialContext ic = new InitialContextO; 15. // insert code here 16. DataSource ds = (DataSource) obj; 17.} Which code, inserted at Line 15, portably looks up the injected resource?
Options
- AObject obj = ic.lookup("employeeDB");
- BObject obj = ic.lookup("dataSource");
- CObject obj = ic.lookup("jdbc/employeeDB");
- DObject obj = ic.lookup("javacomp/env/employeeDB");
- EObject obj = ic.lookup("java:comp/env/jdbc/employeeDB");
How the community answered
(39 responses)- A8% (3)
- B15% (6)
- C3% (1)
- D3% (1)
- E72% (28)
Community Discussion
No community discussion yet for this question.