OOD | Data Access |
JDBC
edit- ODBC stands for Open Database Connectivity
- JDBC is an API required to communicate to the Database
- Driver allows hardware to communicate to the OS
- java.sql is the package for all JDBC interfaces and classes
- DAO stands for Data Access Object
- Should be appended to any class that deals with the database
- Entity Class is a class of something that can be a table
Steps for JDBC
- Register Driver
- Establish Connection
- Create Statement
- Execute Statement
- executeUpdate() : int
- executeQuery() : ResultSet
- execute() : boolean
Java Persistence API (JPA)
edit- ORM - Object Relational Mapping
- Connects objects to database tables
- Entity Manager methods:
- persists fires an insert query
- merge fires an update query
- remove fires a delete query
- Relationships in JPA are:
- @OneToOne
- @OneToMany
- @ManyToMany
- @ManyToMany