121-130 Flashcards
What is a JDBC driver?
A JDBC driver is a software component that enables a java application to interact with the database.
What is the role of a JDBC driver manager class?
The DriverManager class manages registered drivers. It provides a factory method that returns the instance of a connection.
What are the steps to connect to a database in java?
- Registering the driver class
- Creating a connection
- Creating statement
- Executing Queries
- Closing connection
What is a JDBC Connection interface?
The connection interface maintains a session with the database. It can be used for transaction management
What is the purpose of JDBC Result Set interface?
The ResultSet object represents a row of a table. It can be used to change the cursor pointer and get the information from the database
What is JDBC ResultSetMetaData interface?
The ResultSetMetaData interface returns the information of a table such as total number of columns, column name, column type, etc
What is JDBC DatabaseMetaData interface?
The DatabaseMetaData interface returns the information of a database such as username, driver name, driver version, number of tables, number of views, etc
What do you mean by batch processing in JDBC?
Batch processing helps you to group related SQL statements into a batch and execute them instead of executing a single query
What is the difference between execute, executeQuery and executeUpdate?
execute(String query) - is used to execute any SQL query and it returns TRUE if the result is a ResultSet. The output is FALSE when there is no ResultSet object such as running Insert or Update queries.
executeQuery(String query) - is used to execute Select queries and returns the ResultSet. ResultSet is never returned null even if there are no records matching the query.
executeUpdate(String query) - is used to execute Insert/Update/Delete (DML) statements or DDL statements that returns nothing. The output is int and equals to the row count for DML statements or 0 for DDL statements.