This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “Handling Errors and Processing Command Options”.
1. How many of the following use NULL to indicate failure?
mysql_init(), mysql_real_connect()
a) 0
b) 1
c) 2
d) 3
View Answer
Explanation: Both of the client library routines named ‘mysql_init()’ and ‘mysql_real_connect()’ return a pointer to the connection handler in order to indicate success and NULL to indicate failure.
2. How many of the following does not return a value?
mysql_close(), mysql_init, mysql_real_connect
a) 0
b) 1
c) 2
d) 3
View Answer
Explanation: It is not necessary that every Application Programming Interface call would return a value. For example, the client routine named ‘mysql_close()’ returns void, that is, it does not return a value.
3. Which of these returns a string containing an error message?
a) mysql_error()
b) mysql_errno()
c) mysql_sqlstate()
d) mysql_close()
View Answer
Explanation: The API call named ‘mysql_error()’ returns a string containing an error message. ‘mysql_close()’ does not return any value at all. ‘mysql_errno()’ returns a MySQL-specific numeric code.
4. Which of the following returns a MySQL-specific numeric code?
a) mysql_error()
b) mysql_errno()
c) mysql_sqlstate()
d) mysql_close()
View Answer
Explanation: The API call named ‘mysql_errorno()’ returns a MySQL-specific numeric error code. ‘mysql_error()’ returns a string containing an error message. ‘mysql_close()’ does not return any value at all.
5. Which of the following returns an SQLSTATE code?
a) mysql_error()
b) mysql_errno()
c) mysql_sqlstate()
d) mysql_close()
View Answer
Explanation: The MySQL API call named ‘mysql_sqlstate()’ returns an SQLSTATE code. This SQLSTATE value is more ‘vendor neutral’ because it is based on the ‘ANSI SQL’ and ‘ODBC’ standards.
6. The argument to the function mysql_error() is _______________
a) integer
b) float
c) structure
d) pointer
View Answer
Explanation: The argument to the API functions ‘mysql_error()’, ‘mysql_errno()’ and ‘mysql_sqlstate()’ is a pointer to the connection handler. These should be called after an error occurs.
7. What does mysql_real_connect() return if it fails?
a) integer
b) float
c) structure
d) NULL
View Answer
Explanation: The function ‘mysql_real_connect()’ must complete successfully before any other API functions that require a valid MYSQL connection handler structure can be executed. It returns NULL on failure.
8. The function load_defaults() reads the option files.
a) True
b) False
View Answer
Explanation: The function named ‘load_defaults()’ reads the option files. It takes four arguments. It does not pick up values from the environment settings. All connection parameters can be brought to the argument vector.
9. The –protocol value ‘TCP’ runs on which operating systems?
a) unix only
b) windows only
c) all
d) none
View Answer
Explanation: The connection protocol used by the option ‘–protocol = TCP’ indicates TCP/IP connection to the local or the remote server. Each –protocol value has the set of the permissible OS.
10. All API calls return a value.
a) True
b) False
View Answer
Explanation: In MySQL, not all the API calls return a value. The client routine named ‘mysql_close()’ is one that does not. The API calls that return a value are ‘mysql_sqlstate()’, ‘mysql_error()’ etc.
Sanfoundry Global Education & Learning Series – MySQL Database.
To practice all areas of MySQL Database, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check MySQL Books
- Practice Programming MCQs
- Apply for Programming Internship
- Check Information Technology Books