mode 4 JDBC Flashcards
What is a Design Pattern
Opinionated
It is a solution to a common problem.
What is the DAO design pattern?
Data Access Object
its a design pattern that allows us to serperate the application/business logic from the persistance layer
its how we separate our requirement logic / code and logic for our database
What are the layers in the DAO design pattern?
> DAO Layer - directly accesses the database (using JDBC)
>Service Layer - directly acceses the DAO layer
What are layers??
packages! They will have their own packages
What is the heirachy of full stack
talks to talks to talks to Frontend || ^ V || Backend Controller || ^ V || Service Layer || ^ V || DAO Layer || ^ V ||
What is JDBC?
Java Database Connectivity
> JDBC is technology that allows java to connect to a database
> JDBC is modular. It doesnt connect to any specific DB it can connect to any DB as long as it has the driver
What is needed for you to be able to connect to a database?
> url
> username
> password
> driver for the specific database
Important classes/interfaces that JDBC uses
Important classes/interfaces that JDBC uses DriverManager (class) Connection (interface) Statement (interface) PreparedStatement(interface) CallableStatement(interface) ResultSet (interface)
What are some common errors you may have in JDBC
“No suitable driver found”
the two common reasons wh you’ll see this are:
-you forgot to add the dependency to your gradle…in short, you don’t have a driver at all
-your url has a typo
Does JDBC needs a SPECIFIC format for the driver manager?
JDBC needs a SPECIFIC format to the URL string so that the DriverManager
* can understand which driver that you are using * * For PostgreSQL, the URL format is: * url = jdbc:postrgesql://[endpoint]/[databasename]