Lecture 15 - JDBC Part 1 Flashcards
What is JDBC?
•JDBC (Java database connectivity) is used for accessing databases from Java applications
–This is not specific for servlets
•Information is transferred from relations to objects and vice-versa
–databases optimized for searching/indexing
–objects optimized for engineering/flexibility
What are the seven steps for JDBC?
1. Load the driver
- Define the Connection URL
- Establish the Connection
- Create a Statement object
- Execute a query
- Process the result
- Close the connection
•This is typical for a 2-tier database connection: the application talks directly with the database.
What is the JDBC Java architecture?
•Java code calls JDBC library
•JDBC loads a driver
•Driver talks to a particular database
•Can have more than one driver
–Required if we have more than one database
•Ideal because can change database engines without changing any application code
What does the drivermanager do?
- The DriverManager tries all the drivers
- Uses the first one that works
- When a driver class is first loaded, it registers itself with the DriverManager