This set of Database Multiple Choice Questions & Answers focuses on “Access SQL From a Programming Language”.
1. Which of the following is used to access the database server at the time of executing the program and get the data from the server accordingly?
a) Embedded SQL
b) Dynamic SQL
c) SQL declarations
d) SQL data analysis
Explanation: Embedded SQL, the SQL statements are identified at compile time using a preprocessor. The preprocessor submits the SQL statements to the database system for precompilation and optimization; then it replaces the SQL statements in the application program with appropriate code and function calls before invoking the programming-language compiler.
2. Which of the following header must be included in java program to establish database connectivity using JDBC ?
a) Import java.sql.*;
b) Import java.sql.odbc.jdbc.*;
c) Import java.jdbc.*;
d) Import java.sql.jdbc.*;
Explanation: The Java program must import java.sql.*, which contains the interface definitions for the functionality provided by JDBC.
3. DriverManager.getConnection(_______ , ______ , ______)
What are the two parameters that are included?
a) URL or machine name where server runs, Password, User ID
b) URL or machine name where server runs, User ID, Password
c) User ID, Password, URL or machine name where server runs
d) Password, URL or machine name where server runs, User ID
Explanation: The database must be opened first in order to perform any operations for which this get connection method is used.
4. Which of the following invokes functions in sql?
a) Prepared Statements
b) Connection statement
c) Callable statements
d) All of the mentioned
Explanation: JDBC provides a Callable Statement interface that allows invocation of SQL stored procedures and functions.
5. Which of the following function is used to find the column count of the particular resultset?
d) get Count()
Explanation: The interface ResultSet
has a method, getMetaData(), that returns a ResultSetMetaData object that contains metadata about the result set. ResultSetMetaData, in turn, has methods to find metadata information, such as the number of columns in the result, the name of a specified column, or the type of a specified column.
6. Which of the following is a following statement is a prepared statements?
a) Insert into department values(?,?,?)
b) Insert into department values(x,x,x)
c) SQLSetConnectOption(conn, SQL AUTOCOMMIT, 0)
d) SQLTransact(conn, SQL ROLLBACK)
Explanation:? is used as a placeholder whose value can be provided later.
7. Which of the following is used as the embedded SQL in COBOL?
a) EXEC SQL <embedded SQL statement >;
b) EXEC SQL <embedded SQL statement > END-EXEC
c) EXEC SQL <embedded SQL statement >
d) EXEC SQL <embedded SQL statement > END EXEC;
Explanation: EXEC SQL <embedded SQL statement >; is normally in C.
8. Which of the following is used to distinguish the variables in SQL from the host language variables?
EXEC SQL DECLARE c cursor FOR SELECT ID, name FROM student WHERE tot cred > :credit amount;
9. The update statement can be executed in host language using
a) EXEC SQL update c;
b) EXEC SQL update c into :si, :sn;
EXEC SQL UPDATE instructor SET salary = salary + 100 WHERE CURRENT OF c;
d) EXEC SQL update END-SQL
Explanation: The SQL can be terminated by ; to terminate the sentence.
10. Which of the following is used to access large objects from a database ?
d) all of the mentioned
Sanfoundry Global Education & Learning Series – Database Management System.
- Get Free Certificate of Merit in Database Management System
- Participate in Database Management System Certification Contest
- Become a Top Ranker in Database Management System
- Take Database Management System Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10