b. jdbc:mysql:/panda.armstrong.edu/test
c. jdbc:mysql://panda.armstrong.edu/test
d. jdbc.mysql://panda.armstrong.edu/test
#
14. To connect to a local MySQL database named test, use
a. Connection connection = DriverManager.getConnection(jdbc:mysql://localhost/test);
b. Connection connection = DriverManager.connect(“jdbc:mysql://localhost/test”);
c. Connection connection = DriverManager.getConnection(“mysql:jdbc://localhost/test”);
d. Connection connection = DriverManager.getConnection(“jdbc:mysql://localhost/test”);
#
15. To create a statement on a Connection object conn, use
a. Statement statement = conn.statement();
b. Statement statement = Connection.createStatement();
c. Statement statement = conn.createStatement();
d. Statement statement = connection.create();
#
16. To execute a SELECT statement “select * from Address” on a Statement object stmt, use
a. stmt.execute(“select * from Address”);
b. stmt.executeQuery(“select * from Address”);
c. stmt.executeUpdate(“select * from Address”);
d. stmt.query(“select * from Address”);
17. Which of the following statements are true?
a. You may load multiple JDBC drivers in a program.
b. You may create multiple connections to a database.
c. You may create multiple statements from one connection.
d. You can send queries and update statements through a Statement object.
#
18. Analyze the following code:
ResultSet resultSet = statement.executeQuery
(“select firstName, mi, lastName from Student where lastName “
+ ” = ‘Smith'”);
System.out.println(resultSet.getString(1));
a. If the SQL SELECT statement returns no result, resultSet is null.
b. The program will have a runtime error, because the cursor in resultSet does not point to a row. You must use
resultSet.next() to move the cursor to the first row in the result set. Subsequently, resultSet.next() moves the cursor to
the next row in the result set.
c. resultSet.getString(1) returns the firstName field in the result set.
d. resultSet.getString(1) returns the mi field in the result set.
#
19. Suppose that your program accesses MySQL or Oracle database. Which of the following statements are true?
a. If the driver for MySQL and Oracle are not in the classpath, the program will have a syntax error.