JDBC is a front-end tool for connecting to a server and is similar to ODBC however, JDBC can connect only Java client and it uses ODBC for the connectivity. JDBC is essentially a low level application programming interface. It is called a low level API since any data manipulation, storage and retrieval has to be done by the program itself. Some tools that Provide a higher level of abstraction is expected shortly.
The next question is why we need JDBC, once we have ODBC on hand. We can use the ODBC to connect to all the databases and ODBC is a proven technology. Problem for doing this is ODBC gives a ‘C’ language API, which uses pointer extensively, since Java open JDBC to suit its needs.
Jdbc Driver Tipes
There are various types of driver, identified the sun such that each one has some unique features and facilitates a connection to the database.
JDBC drivers fit into of four categories:
The JDBC-ODBC bridge provides JDBC access via most ODBC drivers. Note that some ODBC binary code and in many cases database client code should be loaded on every client machine which uses this diver, so these types of drivers are more suitable in corporate networks, or for the applications in server code that is written in java 3-tier architecture.
A local-API partly-java driver change JDBC calls to the client API for DBMS or oracle Sybase Informix DB2.since,like bridge driver these driver needs binary code be loaded on every client machine.
A net protocol all java drivers explain JDBC calls into a DBMS-independent net protocol that transforms to a DBMS protocol through the server. This net server middleware is capable to join all java clients to different databases. The explicit protocol that is used depends on the seller. Commonly it is the easiest JDBC alternative. It is like the sellers for this solution may provide products that are suitable for the usage of intranet. To support internet access for these products they must need more extra requirements for security, access through firewalls, etc. many vendors are now adding up JDBC driver for their present database middleware products.
A native protocol driver
JDBC architecture is as follows
JDBC Driver Manager
JDBC Driver Manager
Function of the driver manager is to find out available driver in the system and connect the application to the appropriate database, whenever a connection is requested. However, to help the driver manager identify different types of drivers, each driver should be registered with the driver manager.
Function of the JDBC driver is to accept the SQL calls from the application and convert them into native calls to the database,. However, in this process it may take help from some other drivers or even servers, which depends on the type of JDBC driver we are using. It also is possible that the total functionally of the database server could be built into the driver itself.
JDBC – ODBC Bridge:
Sun soft provides a special JDBC Driver called JDBC-ODBC bridge which can be used to connect any existing database, that is ODBC complaint.
Servlet and JSP technology has become the technology of choice for developing online stores, interactive Web applications, and other dynamic Web sites. Why? This chapter gives a high-level overview of the reasons for its popularity. Later chapters specific details on programming techniques.
A Servlet’s Job
Servlet or java programs which run on application servers, acts as middle layer among the requests coming from http Clients or web browsers and applications or database on the http server. Their work is to work on the following tasks.
Reading the use full information that is sent by the client.
The users generally enter this data in http from a web page. Even the data can also be expected to come from an applet or custom http client program. Chapter 4 discusses how servlet read this data.
Reading HTTP requests sent by the browser.
This single arrow shows that travelling from the client to the web server, but mainly they are two different types, the data which is entered by the user in a form and the other one is behind-the-scenes HTTP information, both of them are very important. The HTTP information which contain cookies, news about media and the schemes the browser can understand like compression.
Getting the results.
This process is needed for ,database to contact, to make an RMI or EJB call, to raise a web service or working on replied data which is in a relational database. But the database may not run on http or return results in html, so that the web browser cannot directly deal with the database. Even if it could, for security reasons, you probably would not want it to.
This argument even can apply for other applications, so we need the middle layer to get the arriving data from http stream for the applications to insert the results in the document.
Sending the useful data to the clients:
The document can send in different formats like (XML OR HTML), binary (GIF images), or in zip files that is layered on top of other underlying format. Though HTML is a common format, servlet /JSP task is to cover the results of HTML.
Send the implicit HTTP response data.
This explains about only an arrow leaving from the web middle layer (the servlet or JSP page) to the client. But there are two types of data sent the document alone and last the scenes HTTP information. But these two types can affect the development, by sending the HTTP data to the server or by setting cookies and caching parameter and others.
Features of JSP
JSP provides an attractive alternative to other dynamic scripting language by offering the following features:
The use of adds versatility to a web application by enabling its execution on any computer.
The compilation process in JSP produces faster results or output.
Separation of logic from display:
The use of JSP permits the HTML-specific static content and a mixture of HTML, Java, and JSP-specific dynamic content to be placed in separate fillies.
Ease of administration
The use of JSP eliminates the need for high-level technical expertise, thereby helping web developers, content creators, and content managers to work together and develop Java-based applications in less time and with less effort.
Ease of use:
All JSP applications run on major web server and operating systems, including Microsoft IIS, Netscape enterprise server, I Planet web server, and apache web server. These applications are available on Windows NT, windows 2000, and solaris7.
Competing Products across Platforms:
Competing products include active server pages (ASP), hypertext pre processor(PKP) and Java script.
JSP versus ASP:
ASP is the immediate competing technology from Microsoft. The dynamic content of JSP is written in Java, in contrast to that of ASP, which is written using an ASP-specific language, such as VBScript. As a result, complex applications can use the power of Java to result and embed Java components in JSP applications, second, JSP is portable to other operating systems and servers in contrast to the allegiance of ASP to windows NT/2000and IIS.
JSP versus PHP:
PHP is similar to ASP and JSP to a certain extent. PHP is a free, open-source, HTML-embedded, server-side scripting language, with basic HTML knowledge, however, a VBScript programmer can write ASP applications and a Java programmer can create JSP applications, whereas PHP requires learning an entirely new language, second by virtue if the power of Java, JSP has access to an extensive API for networking, database access, and objects distribution.
JSP Objects & its Scopes
In JSP there are two types of objects.
Implicit objects are automatically created.
Explicit objects are created using actions.
Whenever a request has been made for a JSP PAGE, JSP page will create two types of objects. They are:
Implicit objects are automatically created by the JSP web developers can use this objects for their processing.
Explicit objects are created thought actions. Scripting code is used to create these explicit objects. Every explicit object has some visible attribute. Scripting elements can access the explicit objects thought scripting-level variables.
JSP defines several scopes for JSP objects.
JSP defines several scopes for objects. Scopes are used to indicate the context in which the bean should be made available.
Four types of scopes. They are:
While process the request, the JSP page can create and /or the some Java objects.
Scopes are used to indicate the context in which the dean should be made available in JSP there are four scopes are available. They are:
It is the default scopes for all the Java objects. It is used to indicate that the objects are only available on the current page. Once the response is sent back or the request is forwarded somewhere else all the object reference, which has the page scope, will be released object that contains
Page scope is stored in the page Content object of the current page.
The request scope is used to indicate that the objects are only available for the current client request. If the request is forwarded to a resource in the same runtime, the Object is still available. Once the request is processed, all the object reference, which has the request scope, will be released. Objects that contain request scope will be released. Object references that contain request scope are stored in the request Object.
The session scope indicates that the available to all pages during the life of the current session. All references to the objects shall be released after the associated session ends. References to objects with session scope are stored in the session objects associated with the page activation.
The application scope indicates that it is available to all pages that share the same context object references which contain the application scope will be released when the runtime environment reclaims the servlet context objects references that contain the application scope are stored are stored in the application objects associated with the page activation.
Directives And Actions:
JSP elements can be directives or actions. Directives elements provide global information for the translation phase. Actions elements provide for the request-processing phase. New action can be created from the tag extension mechanism.
Elements can be directives or actions. Directive elements are used to provide global information, which is not dependent for any specific received by the JSP page. For example directive elements can be used to include the external file inside the JSP PAGE.
Action elements provide information, which is dependent on the details of the specific request received by the JSP page.
Directive elements provide information for the compilation/translation phase.
Action can create some objects and may make available to the scripting element. Action elements follow the syntax of XML elements.
JSP contains a tag extension mechanism that enables the addition of new actions. Because of the mechanism JSP can b easily portable. Actions can be customized to provide access to the attribute values and to their body. Custom action be nested and their bodies can include scripting elements.
Two distinct ways to access ODBC data sources with DAO the Microsoft Jet database engine DBC direct Microsoft jet provides a broad range of functionality. It handles many of the details of establishing and managing connection, translating queries into a form acceptable to the server, and managing returned data in some cases, if you want to bypass the micro soft Jet database engine and use DAO to make calls directly to the ODBC driver manager. This functionality is available through ODBC Direct.
The following steps offer a “quick start” to accessing ODBC data:
Use the ODBC data source manager in the windows control panel to setup your ODBC data source and assign it a data
Source name (DSN)
In your Visual Basic code, set an ODBC connect string that references the data source. The connect string is used to establish a connection to the data source
Create a new table def object and set it’s connect string to the value specified in step two.
Append the table to the table defs collection
Open a record-set object on the linked table. This record-set
7. Object contains data in your OBDC data source and you can manipulate it using the properties and methods of a record-set object.