JDBC Interview Questions and Answers
Question - 71 : - What is the difference between executing, executeQuery, executeUpdate in JDBC?
Answer - 71 : -
execute(): it can be used for any kind of SQL Query.
executeQuery() : it can be used for select query.
executeUpdate(): it can be used to change/update table.
Question - 72 : - What is database connection pooling? Advantages of using a connection pool?
Answer - 72 : -
Connection pooling means connections will be stored in the cache and we can reuse them in future.
Advantage:
- It is faster
- Connection pooling becomes easier to diagnose and analyze database connection.
Question - 73 : - What is the function of DriverManager class?
Answer - 73 : -
It is an interface between user and drivers. DriverManager tracks all the activity between a database and the appropriate driver.
Question - 74 : - What is the meaning of batch updates?
Answer - 74 : -
Batch updates means executing a set/group of SQL queries all at once.
Batch updates can be used only for insert, update and delete but not for select query.
Question - 75 : - How many packages are available in JDBC API?
Answer - 75 : -
Two types of packages are available in JDBC API
Question - 76 : - What is the return type of execute, executeQuery and executeUpdate?
Answer - 76 : -
Return type of execute is Boolean
Return type of executeQuery is ResultSet object
Return type of executeUpdate is int
Question - 77 : - Result Set’s index Starts with 0 or 1?
Answer - 77 : -
Result Set’s index starts with 1.
Question - 78 : - What is the role of Class.forName while loading drivers?
Answer - 78 : -
Class.forName creates an instance of JDBC driver and register with DriverManager.
Question - 79 : - JDBC-ODBC Bridge is multi-threaded or not?
Answer - 79 : -
No, JDBC-ODBC Bridge uses synchronized methods to serialize all the calls made to ODBC.
Question - 80 : - Which interface handles transaction management in JDBC?
Answer - 80 : -
Connection interface handles transaction management in JDBC. It provides method for commit (), rollback () etc.