Question 1
Which arguments does DriverManager.getConnection accept to open a database connection?
A. A datasource JNDI name only
A JNDI datasource lookup goes through DataSource, a different mechanism than getConnection.
B. A JDBC URL, optionally followed by a username and passwordCorrect answer
Correct: the overloads take a JDBC URL, optionally with a username and password.
C. A Connection object to clone
getConnection opens a new connection from a URL, not by cloning an existing one.
D. A driver class name and a port number
Host and port are embedded in the URL; a separate driver class and port pair is not an argument form.
Explanation
DriverManager.getConnection is called with a JDBC URL, optionally followed by a username and password or a Properties object. The URL itself carries the host and port details, and datasource-style lookups use a separate mechanism.