JDBC Flashcards
What is JDBC?
Java Database Connectivity (JDBC) is a Java API to connect and execute queries with a database. The classes and interfaces of the JDBC allow the application to send requests made by the user to the specified database
What are the core interfaces/classes in JDBC?
DriverManager Connection Statement PreparedStatement ResultSet SQLException RowID
What is a stored procedure and how would you call it in Java?
It is a prepared SQL code that can be saved so that it can be called over and over again. To call it in Java, you would use the CallableStatement interface.
What is the difference between Statement and PreparedStatement?
Statement is used to execute string based SQL queries
PreparedStatement is used to execute SQL queries that contain parameters
Steps to executing an SQL query using JDBC?
- Establish a connection to the database
- Create a statement
- Execute a query
- If the query returns a result, process the result using ResultSet
- Close the connection
How to execute stored procedures using JDBC?
Which interface is responsible for transaction management?
Connection interface provides methods to manage transactions