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
View Answer
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.*;
View Answer
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
View Answer
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
View Answer
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?
a) getMetaData()
b) Metadata()
c) getColumn()
d) get Count()
View Answer
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)
View Answer
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;
View Answer
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?
a) .
b) –
c) :
d) ,
View Answer
Explanation:
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;
c)
EXEC SQL UPDATE instructor SET salary = salary + 100 WHERE CURRENT OF c;
d) EXEC SQL update END-SQL
View Answer
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 ?
a) setBlob()
b) getBlob()
c) getClob()
d) all of the mentioned
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – Database Management System.
- Practice Programming MCQs
- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Practice RDBMS MCQ
- Check Computer Science Books