Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. List various types of JDBC drives. Explain JDBC-ODBC bridge driver Type 1: JDBC-ODBC bridge Type 2: JDBC-native API Type 3:100% pure java, JDBC network Type 4:100% java JDBC-ODBC bridge This category works with ODBC drivers supplied by your database vendor or a third party. To use the bridge, you must first have an ODBC driver specifically for you database and additional software that you need for connectivity. Using ODBC also requires configuring on your system a DNS that represents the target database. Advantages 1) It offers the ability to connect to almost all databases on almost all platforms. 2) It may be the only way to gain access to some low and desktop database and application Disadvantages 1) ODBC driver must also be loaded on the target machine. 2) Translation between JDBC and ODBC affects performance
  2. 2. Describe the two –tier and three –tier database design of JDBC API with neat diagram. Two Tier Architecture:In a two tier model a java application is designed to interact directly with the database. Application functionality is divided into these two layers: 1) Application Layer: Including the JDBC driver, business logic and user interface 2) Database Layer: including RDBMS The interface to the database is handled by the Java Database Connectivity(JDBC) Driver appropriate to the particularly database management system being accessed. The JDBC Driver passes SQL statements to the database and returns the results of those statements to the application. A client/server configuration is the special case of the two tier model where the database is located on another machine referred to as the server. The application runs on the client machine which is connected to the server over a network. Commonly the network is an Intranet using dedicated database servers to support multiple clients but it can just as easily be the internet. Three Tier Architecture:-In the three tier model, the client typically sends requests to an application server, forming the middle tier. The application server interprets these requests and formats the necessary SQL statement to fulfill These requests, and sends them to the database. The database process the SQL statements and sends result back to the application server, which then sends them to the client. Following are some advantages of Three-tier architecture: 1. Performance can be improved by separating the application server and database server 2. Business logic is clearly separated from the database. 3. Client application can use a simple protocol such as CGI to access services. The three-tier model show in following fig is a common in web application. In this scenario, the client tier is frequently implemented in a browse on a client machine, the middle tier is
  3. 3. implemented in a web server with a Servlet engine and the database management system runs on a dedicated database server. Following are the main components of three tier architecture 1. Client Tier: - Typically, this is thin presentation layer that may be implemented using a web browser 2. Middle Tier :- This tier handles the business or application logic . This may be implemented using a Servlet engine such as Tomcat or an application server such as JBOSS. The JDBC driver also resides in this layer. 3. Data source layer: This component includes the RDBMS Drive Manager: Driver Manager is a static class in the Java Software Development Kit (J2SDK). Driver Manager manages the set of Java Database Connectivity (JDBC) drivers that are available for an application to use. Applications can use multiple JDBC drivers concurrently if necessary. Each application specifies a JDBC driver by using a Uniform Resource Locator (URL). By passing a URL for a specific JDBC driver to the Driver Manager, the application informs the Driver Manager about which type of JDBC connection should be returned to the application. Before this can be done, the Driver Manager must be made aware of the available JDBC drivers so it can hand out connections. By making a call to the Class.forName method, it loads a class into the running Java virtual machine (JVM) based on its string name that is passed into the method. Connection: Connection is a interface. It allows to establish connection between data source and application i.e program written by the user. Connection interface helps by providing the different methods for transactions and error handling. Different approaches can be used to establish a connection with the database. 1. DriverManager.getConnection (string url) 2. DriverManager.getConnection (string url, String user,Stringurl) 3. Connection con= DriverManager.getConnection (string url)
  4. 4. Explain necessity of JDBC-ODBC bridge driver i. The JDBC type1 driver, also known as the JDBC-ODBC bridge, is a database driver implementation that employs the ODBC driver to connect to the database. ii. The driver converts JDBC method calls into ODBC function calls. iii. The driver is platform-dependent as it makes use of ODBC which in turn depends on native libraries of the underlying operating system the JVM is running upon. iv. Also, use of this driver leads to other installation dependencies; for example, ODBC must be installed on the computer having the driver and the database must support an ODBC driver. v. The use of this driver is discouraged if the alternative of a pure-Java driver is available. vi. The other implication is that any application using a type 1 driver is non-portable given the binding between the driver and platform. vii. This technology isn't suitable for a high-transaction environment. Type 1 drivers also don't support the complete Java command set and are limited by the functionality of the ODBC driver.