JDBC Metadata Database - Quiz Explanation
The answers you selected are indicated below, along with the text that explains the correct answers.
1.
Why would you use a
Statement
object in the Brazilian Hospital Project?
Please select the best answer.
A.
To send a
ResultSet
to a data source
B.
To send a SQL
Statement
to a data source
C.
To send a scroll command to the cursor
D.
To set a user password
The correct answer is B.
The
Statement
object is to supply the argument in one of the execute methods, making the connection to the data source. Answer A is incorrect.
ResultSet
objects are not sent, they are returned. Answer C is incorrect because scrolling is performed after a
result set
is returned. Answer D is incorrect because user passwords are set in a system dependent mechanism.
2.
Why would you want to know about the database meta-data in the Brazilian Hospital Project?
Please select the best answer.
A.
To find out information about the database driver, DBMS, table column names, or other information about the hospital databases
B.
To find out if the data contained in a column for each of the doctors and hospitals is accurate
C.
To find out whether the rows and columns in each database are complete
D.
To create the database tables
The correct answer is A.
The
DatabaseMetaData
class provides a way to get system information. The other information in answers B and C are specific pieces of content in the database. Answer D is incorrect because meta-data methods do not provide a means to manipulate data or tables.
3. Which of the following methods is used to retrieve database product name from JDBC metadata?
Please select
the best answer
.
A.
getDatabaseProductVersion()
B.
getUserName()
C.
getDatabaseProductName()
D.
getDriverVersion()
The correct answer is C.
getDatabaseProductName() because this method, provided by the DatabaseMetaData interface in JDBC, is specifically designed to return the name of the database product (such as "Oracle" or "MySQL"). It allows developers to programmatically access the database product name, which can be useful for database management tasks, logging, or when writing code that supports multiple database systems. The other methods retrieve different metadata, such as product version or user name, but not the product name itself.