JDBC Flashcards
What is database
Collection of information
Relational database
Database that uses table to relate the information
How many key interfaces we use in JDBC?
4 key interfaces
Where does the concrete classes that implement the interfaces comes from?
from JDBC driver
what to understand properly among the jars for different databases?
Each databases have different jar files with these classes
What are the key interfaces in JDBC?
Driver, Connection, Statement, ResultSet
What are the different interfaces mean?
Driver: How to connect to the database
Connection: How to communicate to the database
Statement: How to run the query
ResultSet: Knows what was returned by the SQL queries
Where do all the databases classes lies?
java.sql
What is the JDBC URL format?
It has three parts:
- jdbc -> Protocol
- oracle -> Product/Vendor Name
- localhost:8080/Ganesh -> DB connection details
all seperated by ‘:’
What are the two ways to get a connection?
DriverManager or Datasource
What we should use? DriverManager or Datasource?
Datasource.
Datasource is a factory and it has more features than DriverManager. It can pool connections and store database connection outside our application
Where does the implementation class for connection exists?
Inside driver jar
What is the use of Class.forName()?
It loads a class. It lets the DriverManager use a Driver even if the JAR doesn’t have ‘META-INF/services/java.sql.Driver file’
What does the statement represents?
It represents the SQL statement that you want to run using the connection
What is the default type of ResultSet
TYPE_FORWARD_ONLY mode
What are the three modes of ResultSet type?
- TYPE_FORWARD_ONLY
- TYPE_SCROLL_INSENSITIVE
- TYPE_SCROLL_SENSITIVE