ISYS 316 Advanced Java Programming Chapter 32 Java Database Programming

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

________ is an attribute or a set of attributes that uniquely identifies the relation.

A superkey

Which of the following are interfaces?

A. Connection B. Statement C. ResultSet

What information may be obtained from a DatabaseMetaData object?

A. database URL and product name B. JDBC driver name and version C. maximum number of connections to the database D. maximum table name length and maximum number of columns in a table

Suppose that your program accesses MySQL or Oracle database. Which of the following statements are true?

B. If the driver for MySQL and Oracle are not in the classpath, the program will have a runtime error, indicating that the driver class cannot be loaded. D. If the database is not available, the program will have a runtime error, when attempting to create a Connection object.

Analyze the following code: ResultSet resultSet = statement.executeQuery ("select firstName, mi, lastName from Student where lastName " + " = 'Smith'"); System.out.println(resultSet.getString(1));

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.

SQL ________ statements may change the contents of a database.

B. UPDATE C. DELETE D. INSERT

Which of the following statements loads the JDBC-ODBC driver?

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")

Invoking Class.forName method may throw ___________.

ClassNotFoundException

To connect to a local MySQL database named test, use

Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/test");

_________ specify the permissible values for an attribute.

Domain constraints

In a relational data model, _________ imposes constraints on the data.

Integrity

To create a statement on a Connection object conn, use

Statement statement = conn.createStatement();

In a relational data model, _________ defines the representation of the data

Structure

To retrieve all courses with more than 3 credit hours, you write select * from Course where numOfCredits > 3; Is this statement correct?

Yes

Database meta data are retrieved through ____________.

a Connection object

Result set meta data are retrieved through ____________.

a ResultSet Object

What is the return value from stmt.executeUpdate("insert into T values (100, 'Smith')")

an int value indicating how many rows are effected from the invocation

Suppose a callable statement is created as follows: CallableStatement callableStatement = connection.prepareCall( "{call sampleProcedure(?, ?, ?)}"); Assume that the second parameter is an OUT parameter with value John. To register this parameter, use

callableStatement.registerOutParameter(2, java.sql.Types.STRING);

Suppose a callable statement is created as follows: CallableStatement callableStatement = connection.prepareCall( "{call sampleProcedure(?, ?, ?)}"); Assume that the first parameter is an IN parameter with value John. To set this parameter value, use

callableStatement.setString(1, "John");

Where is com.mysql.jdbc.Driver located?

in a JAR file mysqljdbc.jar downloadable from the book's Companion Website

A database URL for a MySQL database named test on host panda.armstrong.edu is ________.

jdbc:mysql://panda.armstrong.edu/test

A database URL for an access database source test is ________.

jdbc:odbc:test

What information may be obtained from a ResultSetMetaData object?

number of columns in the result set

If a prepared statement preparedStatement is a SQL SELECT statement, you execute the statement using _________.

preparedStatement.executeQuery();

Suppose a prepared statement is created as follows: Statement preparedStatement = connection.prepareStatement ("insert into Student (firstName, mi, lastName) " + "values (?, ?, ?)"); To set a value John to the first parameter, use

preparedStatement.setString(1, "John");

To execute a SELECT statement "select * from Address" on a Statement object stmt, use

stmt.executeQuery("select * from Address");


Ensembles d'études connexes

Principles of Marketing Chapter 11 Quiz

View Set

Informatikai logika alapjai 1.zh

View Set