Assume that dbURL, userName, and password are valid. Which code fragment can be inserted at line n1 to enable the code to print Connection Established?
A.
Properties prop = new Properties(); prop.put ("user", userName); prop.put ("password", password); con = DriverManager.getConnection (dbURL, prop);
B.
con = DriverManager.getConnection (userName, password, dbURL);
C.
Properties prop = new Properties(); prop.put ("userid", userName); prop.put ("password", password); prop.put("url", dbURL); con = DriverManager.getConnection (prop);
D.
con = DriverManager.getConnection (dbURL); con.setClientInfo ("user", userName); con.setClientInfo ("password", password);
A is the answer,
public static Connection getConnection(String url,
Properties info)
Parameters:
url - a database url of the form jdbc:subprotocol:subname
info - a list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and "password" property should be included
upvoted 1 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
steefaand
5 months, 4 weeks agoAVB22
2 years, 9 months ago