JDBC Flashcards

1
Q

What is JDBC?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the core interfaces/classes in JDBC?

A
DriverManager
Connection
Statement
PreparedStatement
ResultSet
SQLException
RowID
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a stored procedure and how would you call it in Java?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between Statement and PreparedStatement?

A

Statement is used to execute string based SQL queries

PreparedStatement is used to execute SQL queries that contain parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Steps to executing an SQL query using JDBC?

A
  1. Establish a connection to the database
  2. Create a statement
  3. Execute a query
  4. If the query returns a result, process the result using ResultSet
  5. Close the connection
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to execute stored procedures using JDBC?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which interface is responsible for transaction management?

A

Connection interface provides methods to manage transactions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly