Briefly answer the following questions.
- Explain the following terms: Cursor, Embedded SQL, JDBC, SQLJ, stored procedure.
- What are the differences between JDBC and SQLJ? \Nhy do they both exist?
- Explain the term stored procedure, and give examples why stored procedures are useful.
Explain how the following steps are performed in JDBC:
- Connect to a data source.
- Start, commit, and abort transactions.
- Call a stored procedure. How are these steps performed in SQLJ?
Compare exception handling and handling of warnings ill embedded SQL, dynamic SQL, .IDBC, and SQL.I.
Answer the following questions.
- Why do we need a precompiler to translate embedded SQL and SQL.J? Why do we not need a precompiler for .IDBC?
- SQL.J and embedded SQL use variables in the host language to pass parameters to SQL queries, whereas .JDBC uses placeholders marked with a ''1'. Explain the difference, and why the different mechanisms are needed.
A dynamic web site generates HTML pages from information stored in a database. Whenever a page is requested, is it dynamically assembled from static data and data in a database, resulting in a database access. Connecting to the database is usually a time-consuming process, since resources need to be allocated, and the user needs to be authenticated. Therefore, connection pooling--setting up a pool of persistent database connections and then reusing them for different requests can significantly improve the performance of database-backed websites. Since servlets can keep information beyond single requests, we can create a connection pool, and allocate resources from it to new requests.
Write a connection pool class that provides the following methods:
- Create the pool with a specified number of open connections to the database system.
- Obtain an open connection from the pool.
- Release a connection to the pool.
- Destroy the pool and close all connections.