Lecture 17 - Servlets and Databases:Advanced Topics Flashcards
1
Q
Describe what the best JDBC driver type is and why?
A
- Type 1 drivers are only appropriate if you are already using an ODBC connection and want to reuse it from a Java application. Otherwise they are not a good choice because the multiple levels of translation from JDBC to ODBC to the database are inefficient.
- Type 3 drivers are used to connect from a database client to a remote server. From that point on the server itself will need another type of driver to connect to the database.
- In most cases we will be choosing between a type 2 driver and type 4 driver. Since a type 4 driver has no levels of translation between Java and another API, we would expect a type 4 driver to be the best option.
2
Q
What are the disadvantages of using JDBC driver types?
A
•Connecting directly to a database is not the best way for web applications
–Better: connect to a data source that provides support for connection pooling
•Connection pool
–Responsible for creation and management of DB connections
–Enables reuse
–Avoids costly opening and closing of connections
–Managed transparently by data source
3
Q
What is JNDI?
A
• Stands for: Java Naming and Directory Interface
- Standard API for making resources available through central point
- Consistent interface to access resource independent of implementation
- Provides global namespace for resources to Java apps
4
Q
The complete picture?
A
5
Q
What is the diagram for O/R mapping via DAO Pattern?
A