Assuming variable env is a reference to a hashtable containing the parameters necessary to
obtain the JNDI initial context, which of the following obtains a JDBC data source named
MyDataSource?
A.
DataSource ds;
try {
ctx = new InitialContext(env);
ds = (DataSource) ctx.getNameInNamespace(“MyDataSource”);
} catch (NamingException ne) { }
B.
DataSource ds;
try {
ctx = new InitialContext(env);
ds = (DataSource) ctx.getURLOrDefaultInitCtx(“MyDataSource”);
} catch (NamingException ne) { }
C.
DataSource ds;
try {
ctx = new InitialContext(env);
ds = (DataSource) ctx.getConnection(“MyDataSource”);
} catch (NamingException ne) { }
D.
DataSource ds;
try {
ctx = new InitialContext(env);
ds = (DataSource) ctx.lookup(“MyDataSource”);
} catch (NamingException ne) { }