You are on page 1of 112

Privacy-Preserving Public Auditing for

Secure Cloud Storage


CONTENTS

1. INTRODUCTION

1.1 INTRODUCTION TO PROJECT


1.2 PURPOSE OF THE PROJECT
1.3 EXISTING SYSTEM
1.4 PROPOSED SYSTEM

2. SYSTEM ANALYSIS

2.1. STUDY OF THE SYSTEM


2.2. INPUT & OUTPUT REPRESENTATION
2.3. PROCESS MODELS USED WITH JUSTIFICATION
2.4. SYSTEM ARCHITECTURE

3. FEASIBILITY STUDY

3.1. TECHNICAL FEASIBILITY


3.2. OPERATIONAL FEASIBILITY
3.3. ECONOMIC FEASIBILITY

4. REQUIREMENT SPECIFICATIONS

4.1. FUNCIONAL REQUIREMENTS


4.2. PERFORMANCE REQUIREMENTS
4.3. SOFTWARE REQUIREMENTS
4.4. HARDWARE REQUIREMENTS
4.4.1. INTRODUCTION TO JAVA
4.4.2. AWT and Swings
4.4.3. JDBC
4.4.4. Oracle
4.4.5. HTML
4.4.6. Java Script

5. SYSTEM DESIGN

5.1 . INTRODUCTION
5.2 UML DIAGRAMS
5.3 NORMALIZATION
5.4 DATA DICTIONARY
6. OUTPUT SCREENS

7. SYSTEM TESTING

7.1 INTRODUCTION TO TESTING


7.2 TESTING STRATEGIES

8. SYSTEM SECURITY

8.1 INTRODUCTION
8.2 SECURITY IN SOFTWARE
1.1 INTRODUCTION TO THE PROJECT:

Cloud Computing is the long dreamed vision of computing as a utility, where users can remotely
store their data into the cloud so as to enjoy the on-demand high quality applications and services from a
shared pool of configurable computing resources. By data outsourcing, users can be relieved from the
burden of local data storage and maintenance. However, the fact that users no longer have physical
possession of the possibly large size of outsourced data makes the data integrity protection in Cloud
Computing a very challenging and potentially formidable task, especially for users with constrained
computing resources and capabilities. Thus, enabling public auditability for cloud data storage security
is of critical importance so that users can resort to an external audit party to check the integrity of
outsourced data when needed. To securely introduce an effective third party auditor (TPA), the
following two fundamental requirements have to be met: 1) TPA should be able to efficiently audit the
cloud data storage without demanding the local copy of data, and introduce no additional on-line burden
to the cloud user; 2) The third party auditing process should bring in no new vulnerabilities towards user
data privacy. In this paper, we utilize and uniquely combine the public key based homomorphic
authenticator with random masking to achieve the privacy-preserving public cloud data auditing system,
which meets all above requirements. To support efficient handling of multiple auditing tasks, we further
explore the technique of bilinear aggregate signature to extend our main result into a multi-user setting,
where TPA can perform multiple auditing tasks simultaneously. Extensive security and performance
analysis shows the proposed schemes are provably secure and highly efficient.

1.2 PURPOSE OF THE PROJECT:


Cloud Computing makes these advantages more appealing than ever, it also brings new and
challenging security threats towards users’ outsourced data. Since cloud service providers (CSP) are
separate administrative entities, data outsourcing is actually relinquishing user’s ultimate control over
the fate of their data. As a result, the correctness of the data in the cloud is being put at risk due to the
following reasons. As users no longer physically possess the storage of their data, traditional
cryptographic primitives for the purpose of data security protection can not be directly adopted. Thus,
how to efficiently verify the correctness of outsourced cloud data without the local copy of data files
becomes a big challenge for data storage security in Cloud Computing. Note that simply downloading
the data for its integrity verification is not a practical solution due to the expensiveness in I/O cost and
transmitting the file across the network. Besides, it is often insufficient to detect the data corruption
when accessing the data, as it might be too late for recover the data loss or damage. Considering the
large size of the outsourced data and the user’s constrained resource capability, the ability to audit the
correctness of the data in a cloud environment can be formidable and expensive for the cloud users.
Therefore, to fully ensure the data security and save the cloud users’ computation resources, it is of
critical importance to enable public auditability for cloud data storage so that the users may resort to a
third party auditor (TPA), who has expertise and capabilities that the users do not, to audit the
outsourced data when needed. Based on the audit result, TPA could release an audit report, which would
not only help users to evaluate the risk of their subscribed cloud data services, but also be beneficial for
the cloud service provider to improve their cloud based service platform .In a word, enabling public risk
auditing protocols will play an important role for this nascent cloud economy to become fully
established, where users will need ways to assess risk and gain trust in Cloud.

1.3 EXISTING SYSTEM:

In the Existing System, Cloud Computing brings new and challenging security threats towards
users’ outsourced data. Cloud Service Providers (CSP) are separate administrative entities, data
outsourcing is actually relinquishing user’s ultimate control over the fate of their data. As a result, the
correctness of the data in the cloud is being put at risk due to the following reasons. First of all, although
the infrastructures under the cloud are much more powerful and reliable than personal computing
devices, they are still facing the broad range of both internal and external threats for data integrity.
Secondly, for the benefits of their own, there do exist various motivations for cloud service providers to
behave unfaithfully towards the cloud users regarding the status of their outsourced data.

1.4 PROPOSED SYSTEM :

The proposed system can be summarized as the following three aspects:

1) We motivate the public auditing system of data storage security in Cloud Computing and provide a
privacy-preserving auditing protocol, i.e., our scheme supports an external auditor to audit user’s
outsourced data in the cloud without learning knowledge on the data content.
2) To the best of our knowledge, our scheme is the first to support scalable and efficient public auditing
in the Cloud Computing. In particular, our scheme achieves batch auditing where multiple delegated
auditing tasks from different users can be performed simultaneously by the TPA.
3) We prove the security and justify the performance of our proposed schemes through concrete
experiments and comparisons with the state-of-the-art.
2.1 STUDY OF THE SYSTEM

To provide flexibility to the users, the interfaces have been developed that are accessible through a
browser. The GUI’S at the top level have been categorized as

1. Administrative user interface

2. The operational or generic user interface

The ‘administrative user interface’ concentrates on the consistent information that is practically, part of
the organizational activities and which needs proper authentication for the data collection. These
interfaces help the administrators with all the transactional states like Data insertion, Data deletion and
Date updation along with the extensive data search capabilities.
The ‘operational or generic user interface’ helps the end users of the system in transactions through the
existing data and required services. The operational user interface also helps the ordinary users in
managing their own information in a customized manner as per the included flexibilities

2.2 INPUT & OUTPOUT REPRESENTETION

Input design is a part of overall system design. The main objective during the input design is as
given below:
● To produce a cost-effective method of input.
● To achieve ​the​​ highest possible level of accuracy.
● To ensure that the input is acceptable and understood by the user.

INPUT STAGES​​:
The main input stages can be listed as below:
● Data recording
● Data transcription
● Data conversion
● Data verification
● Data control
● Data transmission
● Data validation
● Data correction

INPUT TYPES​​:
It is necessary to determine the various types of inputs. Inputs can be categorized as follows:
● External inputs, which are prime inputs for the system.
● Internal inputs, which are user communications with the system.
● Operational, which are computer department’s communications to the system?
● Interactive, which are inputs entered during a dialogue.
INPUT MEDIA​​:
At this stage choice has to be made about the input media. To conclude about the input media
consideration has to be given to;
● Type of input
● Flexibility of format
● Speed
● Accuracy
● Verification methods
● Rejection rates
● Ease of correction
● Storage and handling requirements
● Security
● Easy to use
● Portability
Keeping in view the above description of the input types and input media, it can be said that most of the
inputs are of the form of internal and interactive. As
Input data is to be the directly keyed in by the user, the keyboard can be considered to be the most
suitable input device.

OUTPUT DESIGN:

In general are:
● External Outputs whose destination is outside the organization.
● Internal Outputs whose destination is with in organization and they are the User’s main interface
with the computer. Outputs from computer systems are required primarily to communicate the
results of processing to users. They are also used to provide a permanent copy of the results for
later consultation. The various types of outputs
● Operational outputs whose use is purely with in the computer department.
● Interface outputs, which involve the user in communicating directly with the system.
OUTPUT DEFINITION
The outputs should be defined in terms of the following points:
▪ Type of the output
▪ Content of the output
▪ Format of the output
▪ Location of the output
▪ Frequency of the output
▪ Volume of the output
▪ Sequence of the output

It is not always desirable to print or display data as it is held on a computer. It should be decided as
which form of the output is the most suitable.

For Example
● Will decimal points need to be inserted
● Should leading zeros be suppressed.

OUTPUT MEDIA​​:

In the next stage it is to be decided that which medium is the most appropriate for the output. The
main considerations when deciding about the output media are:

● The suitability for the device to the particular application.


● The need for a hard copy.
● The response time required.
● The location of the users
● The software and hardware available.

Keeping in view the above description the project is to have outputs mainly coming under the
category of internal outputs. The main outputs desired according to the requirement specification are:

The outputs were needed to be generated as a hard copy and as well as queries to be viewed on the
screen. Keeping in view these outputs, the format for the output is taken from the outputs, which are
currently being obtained after manual processing. The standard printer is to be used as output media for
hard copies.

2.3 PROCESS MODEL USED WITH JUSTIFICATION

SDLC (Umbrella Model)​​:


SDLC is nothing but Software Development Life Cycle. It is a standard which is used by software
industry to develop good software.
Stages in SDLC​​:

♦ Requirement Gathering
♦ Analysis
♦ Designing
♦ Coding
♦ Testing
♦ Maintenance
Requirements Gathering​​ ​stage​​:

The requirements gathering process takes as its input the goals identified in the high-level
requirements section of the project plan. Each goal will be refined into a set of one or more
requirements. These requirements define the major functions of the intended application, define
operational data areas and reference data areas, and define the initial data entities. Major functions
include critical processes to be managed, as well as mission critical inputs, outputs and reports. A user
class hierarchy is developed and associated with these major functions, data areas, and data entities.
Each of these definitions is termed a Requirement. Requirements are identified by unique requirement
identifiers and, at minimum, contain a requirement title and
textual description.
These requirements are fully described in the primary deliverables for this stage: the Requirements
Document and the Requirements Traceability Matrix (RTM). The requirements document contains
complete descriptions of each requirement, including diagrams and references to external documents as
necessary. Note that detailed listings of database tables and fields are ​not ​included in the requirements
document.
The title of each requirement is also placed into the first version of the RTM, along with the title of
each goal from the project plan. The purpose of the RTM is to show that the product components
developed during each stage of the software development lifecycle are formally connected to the
components developed in prior stages.

In the requirements stage, the RTM consists of a list of high-level requirements, or goals, by title,
with a listing of associated requirements for each goal, listed by requirement title. In this hierarchical
listing, the RTM shows that each requirement developed during this stage is formally linked to a specific
product goal. In this format, each requirement can be traced to a specific product goal, hence the term
requirements traceability​.
The outputs of the requirements definition stage include the requirements document, the RTM, and
an updated project plan.
♦ Feasibility study is all about identification of problems in a project.
♦ No. of staff required to handle a project is represented as Team Formation, in this case only modules
are individual tasks will be assigned to employees who are working for that project.
♦ Project Specifications are all about representing of various possible inputs submitting to the server
and corresponding outputs along with reports maintained by administrator
Analysis Stage​​:

The planning stage establishes a bird's eye view of the intended software product, and uses this to
establish the basic project structure, evaluate feasibility and risks associated with the project, and
describe appropriate management and technical approaches.
The most critical section of the project plan is a listing of high-level product requirements, also referred
to as goals. All of the software product requirements to be developed during the requirements definition
stage flow from one or more of these goals. The minimum information for each goal consists of a title
and textual description, although additional information and references to external documents may be
included. The outputs of the project planning stage are the configuration management plan, the quality
assurance plan, and the project plan and schedule, with a detailed listing of scheduled activities for the
upcoming Requirements stage, and high level estimates of effort for the out stages.

Designing Stage​​:

The design stage takes as its initial input the requirements identified in the approved requirements
document. For each requirement, a set of one or more design elements will be produced as a result of
interviews, workshops, and/or prototype efforts. Design elements describe the desired software features
in detail, and generally include functional hierarchy diagrams, screen layout diagrams, tables of business
rules, business process diagrams, pseudo code, and a complete entity-relationship diagram with a full
data dictionary. These design elements are intended to describe the software in sufficient detail that
skilled programmers may develop the software with minimal additional input.

When the design document is finalized and accepted, the RTM is updated to show that each design
element is formally associated with a specific requirement. The outputs of the design stage are the
design document, an updated RTM, and an updated project plan.

Development (Coding) Stage​​:

The development stage takes as its primary input the design elements described in the approved
design document. For each design element, a set of one or more software artifacts will be produced.
Software artifacts include but are not limited to menus, dialogs, data management forms, data reporting
formats, and specialized procedures and functions. Appropriate test cases will be developed for each set
of functionally related software artifacts, and an online help system will be developed to guide users in
their interactions with the software.
The RTM will be updated to show that each developed artifact is linked to a specific design
element, and that each developed artifact has one or more corresponding test case items. At this point,
the RTM is in its final configuration. The outputs of the development stage include a fully functional set
of software that satisfies the requirements and design elements previously documented, an online help
system that describes the operation of the software, an implementation map that identifies the primary
code entry points for all major system functions, a test plan that describes the test cases to be used to
validate the correctness and completeness of the software, an updated RTM, and an updated project
plan.

Integration & Test Stage​​:

During the integration and test stage, the software artifacts, online help, and test data are migrated
from the development environment to a separate test environment. At this point, all test cases are run to
verify the correctness and completeness of the software. Successful execution of the test suite confirms a
robust and complete migration capability. During this stage, reference data is finalized for production
use and production users are identified and linked to their appropriate roles. The final reference data (or
links to reference data source files) and production user list are compiled into the Production Initiation
Plan.

The outputs of the integration and test stage include an integrated set of software, an online help
system, an implementation map, a production initiation plan that describes reference data and production
users, an acceptance plan which contains the final suite of test cases, and an updated project plan.

♦ Installation & Acceptance Test:

During the installation and acceptance stage, the software artifacts, online help, and initial
production data are loaded onto the production server. At this point, all test cases are run to verify the
correctness and completeness of the software. Successful execution of the test suite is a prerequisite to
acceptance of the software by the customer.
After customer personnel have verified that the initial production data load is correct and the test
suite has been executed with satisfactory results, the customer formally accepts the delivery of the
software.

The primary outputs of the installation and acceptance stage include a production application, a
completed acceptance test suite, and a memorandum of customer acceptance of the software. Finally, the
PDR enters the last of the actual labor data into the project schedule and locks the project as a permanent
project record. At this point the PDR "locks" the project by archiving all software items, the
implementation map, the source code, and the documentation for future reference.

Maintenance​​:
Outer rectangle represents maintenance of a project, Maintenance team will start with requirement
study, understanding of documentation later employees will be assigned work and they will under go
training on that particular assigned category.
For this life cycle there is no end, it will be continued so on like an umbrella (no ending point to
umbrella sticks).
2.4 SYSTEM ARCHITECTURE
Architecture flow​:

The ​client–server model is an approach to ​computer network programming developed at ​Xerox PARC
during the 1970s. It is now prevalent in ​computer networks​. ​Email​, the ​World Wide Web​, and ​network
printing​ all apply the client–server model.

The model assigns one of two roles to the ​computers in a ​network​: ​Client or ​server​. A ​server is a
computer system that selectively shares its ​resources​; a ​client is a computer or ​computer program that
initiates contact with a server in order to make use of a resource. ​Data​, ​CPUs​, ​printers​, and ​data storage
devices​ are some examples of resources.

This sharing of computer resources is called ​time-sharing,​ because it allows multiple people to use a
computer (in this case, the server) at the same time. Because a computer does a limited amount of work
at any moment, a time-sharing system must quickly prioritize its ​tasks​ to accommodate the clients.

Clients and servers exchange messages in a ​request-response ​messaging pattern​: The client sends a
request, and the server returns a response. To communicate, the computers must have a common
language, and they must follow rules so that both the client and the server know what to expect. The
language and rules of communication are defined in a ​communications protocol​. All client-server
protocols operate in the ​application layer​.

Whether a computer is a client, a server, or both, it can serve multiple functions. For example, a single
​ eb server and ​file server ​software at the same time to serve different data to clients
computer can ​run w
making different kinds of requests. Client software can also communicate with server software on the
same computer.​[1] Communication between servers, such as to synchronize data, is sometimes called
inter-server​ or ​server-to-server​ communication.
Feasibility Study:

Preliminary investigation examines project feasibility, the likelihood the system will be useful to the
organization. The main objective of the feasibility study is to test the Technical, Operational and
Economical feasibility for adding new modules and debugging old running system. All systems are
feasible if they are given unlimited resources and infinite time. There are aspects in the feasibility study
portion of the preliminary investigation:
● Technical Feasibility
● Operation Feasibility
Economical Feasibility

3.1 TECHNICAL FEASIBILITY

The technical issue usually raised during the feasibility stage of the investigation includes the following:
● Does the necessary technology exist to do what is suggested?
● Do the proposed equipments have the technical capacity to hold the data required to use the new
system?
● Will the proposed system provide adequate response to inquiries, regardless of the number or
location of users?
● Can the system be upgraded if developed?
Are there technical guarantees of accuracy, reliability, ease of access and data security?

3.2 OPERATIONAL FEASIBILITY


OPERATIONAL FEASIBILITY
User-friendly

Customer will use the forms for their various transactions i.e. for adding new routes, viewing the
routes details. Also the Customer wants the reports to view the various transactions based on the
constraints. Theses forms and reports are generated as user-friendly to the Client.

Reliability

The package wills pick-up current transactions on line. Regarding the old transactions, User will
enter them in to the system.

Security

The web server and database server should be protected from hacking, virus etc

Portability

The application will be developed using standard open source software (Except Oracle) like Java,
tomcat web server, Internet Explorer Browser etc these software will work both on Windows and
Linux o/s. Hence portability problems will not arise.

Availability

This software will be available always.

Maintainability

The system called the ewheelz uses the 2-tier architecture. The 1st tier is the GUI, which is said to be
front-end and the 2nd tier is the database, which uses My-Sql, which is the back-end.
The front-end can be run on different systems (clients). The database will be running at the server.
Users access these forms by using the user-ids and the passwords.
3.3 ECONOMIC FEASILITY

The computerized system takes care of the present existing system’s data flow and procedures
completely and should generate all the reports of the manual system besides a host of other
management reports.

It should be built as a web based application with separate web server and database server. This is
required as the activities are spread through out the organization customer wants a centralized
database. Further some of the linked transactions take place in different locations.

Open source software like TOMCAT, JAVA, Mysql and Linux is used to minimize the cost for the
Customer.
4.1 FUNCTIONAL REQUIREMENTS SPECIFICATION

This application mainly consist four modules

Modules Description

The system is proposed to have the following modules:


● Admin Module
● TPA module
● User module
● Block Verification Module
● Block Insertion Module
● Block Deletion

Admin module:
Admin is allowed to check which user registered and which data is stored in the cloud space area

TPA Module:
TPA check that data is modified or not if modified that information send to user

User Module:
​User can register and he can login with his user id and password and he can upload the data to cloud
space area

Block Verification Module​​:


user can check that the uploaded file is modified by any one or not(like server area)

Block Insertion Module:


​ in the block insertion module user can insert the new block

Block Deletion Module:


In the Block Deletion Module user can Delete the Block

4.2 PERFORMANCE​​ ​REQUIREMENTS

Performance is measured in terms of the output provided by the application. Requirement specification
plays an important part in the analysis of a system. Only when the requirement specifications are
properly given, it is possible to design a system, which will fit into required environment. It rests largely
with the users of the existing system to give the requirement specifications because they are the people
who finally use the system. This is because the requirements have to be known during the initial stages
so that the system can be designed according to those requirements. It is very difficult to change the
system once it has been designed and on the other hand designing a system, which does not cater to the
requirements of the user, is of no use.
The requirement specification for any system can be broadly stated as given below:
The system should be able to interface with the existing system
● The system should be accurate
● The system should be better than the existing system
The existing system is completely dependent on the user to perform all the duties.
4.3 SOFTWARE REQUIREMENTS:

➢ Server side Technology : AWT and Swings.


➢ Client Side Technology : HTML, Javascript
➢ Database : MySQL

4.4 HARDWARE REQUIREMENTS:

➢ Pentium 4 processor

➢ 1 GB RAM

➢ 80 GB Hard Disk Space

4.4.1. INTRODUCTION TO JAVA

About Java​​:

Initially the language was called as “oak” but it was renamed as “java” in 1995.The primary
motivation of this language was the need for a platform-independent(i.e. architecture
neutral)language that could be used to create software to be embedded in various consumer
electronic devices.

● Java is a programmer’s language


● Java is cohesive and consistent
● Except for those constraint imposed by the Internet environment. Java gives the
programmer, full control

Finally Java is to Internet Programming where c was to System Programming.


Importance of Java to the Internet

Java has had a profound effect on the Internet. This is because; java expands the Universe of objects
that can move about freely in Cyberspace. In a network, two categories of objects are transmitted
between the server and the personal computer. They are passive information and Dynamic active
programs. in the areas of Security and probability. But Java addresses these concerns and by doing
so, has opened the door to an exciting new form of program called the Applet.

Applications and applets​​. An application is a program that runs on our Computer under the
operating system of that computer. It is more or less like one creating using C or C++ .Java’s ability
to create Applets makes it important. An Applet I san application, designed to be transmitted over
the Internet and executed by a Java-compatible web browser. An applet I actually a tiny Java
program, dynamically downloaded across the network, just like an image. But the difference is, it is
an intelligent program, not just a media file. It can be react to the user input and dynamically change.

Java Architecture
Java architecture provides a portable, robust, high performing environment for development.
Java provides portability by compiling the byte codes for the Java Virtual Machine, which is then
interpreted on each platform by the run-time environment. Java is a dynamic system, able to load
code when needed from a machine in the same room or across the planet.
Compilation of code
When you compile the code, the Java compiler creates machine code (called byte code)for a
hypothetical machine called Java Virtual Machine(JVM). The JVM is supposed t executed the
byte code. The JVM is created for the overcoming the issue of probability. The code is written and
compiled for one machine and interpreted on all machines .This machine is called Java Virtual
Machine.​
Compiling and interpreting java source code.

During run-time the Java interpreter tricks the byte code file into thinking that it is running on a Java
Virtual Machine. In reality this could be an Intel Pentium windows 95 or sun SPARCstation running
Solaris or Apple Macintosh running system and all could receive code from any computer through
internet and run the Applets.

Simple​​:
Java was designed to be easy for the Professional programmer to learn and to use effectively. If you
are an experienced C++ Programmer. Learning Java will oriented features of C++ . Most of the
confusing concepts from C++ are either left out of Java or implemented in a cleaner, more
approachable manner. In Java there are a small number of clearly defined ways to accomplish a
given task.

Object oriented

Java was not designed to be source-code compatible with any other language. This allowed the Java
team the freedom to design with a blank state. One outcome of this was a clean usable, pragmatic
approach to objects. The object model in Java is simple and easy to extend, while simple types, such
as integers, are kept as high-performance non-objects.

Robust

The multi-platform environment of the web places extraordinary demands on a program, because the
program must execute reliably in a variety of systems. The ability to create robust programs. Was
given a high priority in the design of Java. Java is strictly typed language; it checks your code at
compile time and runtime.

Java virtually eliminates the problems of memory management and deal location, which is
completely automatic. In a well-written Java program, all run-time errors can and should be
managed by your program.

4.4.2 AWT and Swings:

AWT:
Graphical User Interface:
The user interface is that part of a program that interacts with the user of the program. GUI ​is a type
of ​user interface​ that allows ​users​ to ​interact​ with electronic devices with images rather than text
commands. A class library is provided by the Java programming language which is known as Abstract
Window Toolkit (AWT) for writing graphical programs. The Abstract Window Toolkit (AWT) contains
several graphical widgets which can be added and positioned to the display area with a layout manager.
As the Java programming language, the AWT is not platform-independent. AWT uses system peers
object for constructing graphical widgets. A common set of tools is provided by the AWT for graphical
user interface design. The implementation of the user interface elements provided by the AWT is done
using every platform's native GUI toolkit. One of the AWT's significance is that the look and feel of
each platform can be preserved.

Components:

A graphical user interface is built of graphical elements called components. A ​component​ is an object
having a graphical representation that can be displayed on the screen and that can interact with the user.
Components allow the user to interact with the program and provide the input to the program. In the
AWT, all user interface components are instances of class Component or one of its subtypes. Typical
components include such items as buttons, scrollbars, and text fields.

Types of Components:
Before proceeding ahead, first we need to know what containers are. After learning containers we learn
all components in detail.

Containers:

Components do not stand alone, but rather are found within containers. In order to make components
visible, we need to add all components to the container. Containers contain and control the layout of
components. In the AWT, all containers are instances of class Container or one of its subtypes.
Components must fit completely within the container that contains them. For adding components to the
container we will use add() method.

Types of containers:
Basic GUI Logic:

The GUI application or applet is created in three steps. These are:

● Add components to Container objects to make your GUI.


● Then you need to setup event handlers for the user interaction with GUI.
● Explicitly display the GUI for application.

A new thread is started by the interpreter for user interaction when an AWT GUI is displayed. When any
event is received by this new thread such as click of a mouse, pressing of key etc then one of the event
handlers is called by the new thread set up for GUI. One important point to note here is that the event
handler code is executed within the thread.

Creating a Frame:

Method1:

In the first method we will be creating frame by extending Frame class which is defined in java.awt
package. Following program demonstrate the creation of a frame.

import java.awt.*;

public class FrameDemo1 extends Frame

FrameDemo1()

{
setTitle("Label Frame");

setVisible(true);

setSize(500,500);

public static void main(String[] args)

new FrameDemo1 ();

In the above program we are using three methods:

setTitle: For setting the title of the frame we will use this method. It takes String as an argument which
will be the title name.

SetVisible: For making our frame visible we will use this method. This method takes Boolean value as
an argument. If we are passing true then window will be visible otherwise window will not be visible.

SetSize: For setting the size of the window we will use this method. The first argument is width of the
frame and second argument is height of the frame.

Method 2:

In this method we will be creating the Frame class instance for creating frame window. Following
program demonstrate Method2.

import java.awt.*;

public class FrameDemo2


{

public static void main(String[] args)

Frame f = new Frame();

f.setTitle("My first frame");

f.setVisible(true);

f.setSize(500,500);

Types of Components:

1) Labels :

This is the simplest component of Java Abstract Window Toolkit. This component is generally used to
show the text or string in your application and label never perform any type of action.

Label l1 = new Label("One");

Label l2 = new Label("Two");

Label l3 = new Label("Three",Label.CENTER);

In the above three lines we have created three labels with the name “one, two, three”. In the third label
we are passing two arguments. Second argument is the justification of the label. Now after creating
components we will be adding it to the container.
add(l1);

add(l2);

add(l3);

We can set or change the text in a label by using the ​setText( ) ​method. You can obtain the current label
by calling ​getText( )​​. These methods are shown here:

void setText(String ​str​)


String getText( )

2) Buttons :

This is the component of Java Abstract Window Toolkit and is used to trigger actions and other events
required for your application. The syntax of defining the button is as follows :

Button l1 = new Button("One");

Button l2 = new Button("Two");

Button l3 = new Button("Three");

We can change the Button's label or get the label's text by using the Button.setLabel(String) and
Button.getLabel() method.

3) CheckBox:

A ​check box is a control that is used to turn an option on or off. It consists of a small box ​that
can either contain a check mark or not. There is a label associated with each check box that describes
what option the box represents. You change the state of a check box by clicking on it. The syntax of the
definition of Checkbox is as follows :

Checkbox Win98 = new Checkbox("Windows 98/XP", null, true);

Checkbox winNT = new Checkbox("Windows NT/2000");

Checkbox solaris = new Checkbox("Solaris");

Checkbox mac = new Checkbox("MacOS");

The first form creates a check box whose label is specified in first argument and whose group is
specified in second argument​. I​ f this check box is not part of a group, then ​cbGroup m
​ ust be ​null​​.
(Check box groups are described in the next section.) The value true d​ etermines the initial state of the
check box is checked. The second form creates a check box with only one parameter.
To retrieve the current state of a check box, call ​getState( )​​. To set its state, call ​setState( )​​. You can
obtain the current label associated with a check box by calling ​getLabel( )​​. To set the label, call
setLabel( )​​. These methods are as follows:

boolean getState( )
void setState(boolean ​on​)
String getLabel( )
void setLabel(String ​str)​

Here, if ​on i​ s ​true​​, the box is checked. If it is ​false​​, the box is cleared. The string passed in ​str ​becomes
the new label associated with the invoking check box.
4) Radio Button:

This is the special case of the Checkbox component of Java AWT package. This is used as a group of
checkboxes which group name is same. Only one Checkbox from a Checkbox Group can be selected at
a time. Syntax for creating radio buttons is as follows:
CheckboxGroup cbg = new CheckboxGroup();

Checkbox Win98 = new Checkbox("Windows 98/XP", cbg , true);

Checkbox winNT = new Checkbox("Windows NT/2000",cbg, false);

Checkbox solaris = new Checkbox("Solaris",cbg, false);

Checkbox mac = new Checkbox("MacOS",cbg, false);

For Radio Button we will be using CheckBox class. The only difference in Checkboxes and radio button
is in Check boxes we will specify null for checkboxgroup but whereas in radio button we will be
specifiying the checkboxgroup object in the second parameter.

5) Choice:

The Choice class is used to create a pop-up list of items from which the user may choose.
Thus, a Choice control is a form of menu.​ Syntax for creating choice is as follows:

Choice os = new Choice();

/* adding items to choice */

os.add("Windows 98/XP");

os.add("Windows NT/2000");

os.add("Solaris");

os.add("MacOS");
We will be creating choice with the help of Choice class. Pop up list will be creating with the creation of
object, but it will not have any items. For adding items we will be using add() method defined in Choice
class.

To determine which item is currently selected, you may call either ​getSelectedItem( ) ​or
getSelectedIndex( )​​. These methods are shown here:

String getSelectedItem( )
int getSelectedIndex( )

The ​getSelectedItem( ) ​method returns a string containing the name of the item.
getSelectedIndex( ) ​returns the index of the item. The first item is at index 0. By default, the first item
added to the list is selected.

6) List:

List class is also same as choice but the only difference in list and choice is, in choice user can select
only one item whereas in List user can select more than one item. Syntax for creating list is as follows:

List os = new List(4, true);

First argument in the List constructor specifies the number of items allowed in the list. Second argument
specifies whether multiple selections are allowed or not.

/* Adding items to the list */


os.add("Windows 98/XP");

os.add("Windows NT/2000");

os.add("Solaris");

os.add("MacOS");

In list we can retrieve the items which are selected by the users. In multiple selection user will be
selecting multiple values for retrieving all the values we have a method called getSelectedValues()
whose return type is string array. For retrieving single value again we can use the method defined in
Choice i.e. getSelectedItem().

7) TextField:

Text fields allow the user to enter strings and to edit the text using the arrow keys, cut and paste keys.
TextField is a subclass of TextComponent. Syntax for creating list is as follows:

TextField ​tf1 = new TextField(25);

TextField​ tf2 = new TextField();

In the first text field we are specifying the size of the text field and the second text field is created with
the default value.  ​TextField ​(and its superclass ​TextComponent​​) provides several methods that allow
you to utilize a text field. To obtain the string currently contained in the text field, call ​getText( )​​. To set
the text, call ​setText( )​​. These methods are as follows:

String getText( )
void setText(String ​str​)
We can control whether the contents of a text field may be modified by the user by calling ​setEditable(
)​​. You can determine editability by calling ​isEditable( )​​. These methods are shown here:

boolean isEditable( )
void setEditable(boolean ​canEdit​)

isEditable( ) ​returns ​true ​if the text may be changed and ​false ​if not. In ​setEditable( )​​, if ​canEdit ​is
true​​, the text may be changed. If it is ​false​​, the text cannot be altered.
There may be times when we will want the user to enter text that is not displayed, such as a
password. We can disable the echoing of the characters as they are typed by calling ​setEchoChar( )​​.

8) TextArea:

TextArea is a multiple line editor. Syntax for creating list is as follows:

TextArea area = new TextArea(20,30);

Above code will create one text area with 20 rows and 30 columns.  ​TextArea ​is a subclass of
TextComponent​​. Therefore, it supports the ​getText( )​​, ​setText( )​​, ​getSelectedText( )​​, ​select( )​​,
isEditable( )​​, and ​setEditable( ) ​methods described in the preceding section.
THE JAVA LIBRARY
TextArea ​adds the following methods:

void append(String ​str)​


void insert(String ​str​, int ​index​)
void replaceRange(String ​str,​ int ​startIndex,​ int ​endIndex​)
The ​append( ) ​method appends the string specified by ​str t​ o the end of the current text. ​insert( ) ​inserts
the string passed in ​str a​ t the specified index. To replace text, call ​replaceRange( )​​. It replaces the
characters from ​startIndex ​to ​endIndex​–1, with the replacement text passed in ​str.

Layout Managers:

A layout manager automatically arranges controls within a window by using some type of algorithm.
Each ​Container ​object has a layout manager associated with it. A layout manager is an instance of any
class that implements the ​LayoutManager ​interface. The layout manager is set by the ​setLayout( )
method. If no call to ​setLayout( ) ​is made, then the default layout manager is used. Whenever a
container is resized (or sized for the first time), the layout manager is used to position each of the
components within it. The ​setLayout( ) ​method has the following general form:

void setLayout(LayoutManager ​layoutObj)​

Here, ​layoutObj ​is a reference to the desired layout manager. If you wish to disable the layout manager
and position components manually, pass ​null ​for ​layoutObj. I​ f we do this, you will need to determine the
shape and position of each component manually, using the setBounds( ) method defined by Component.

Void setBounds(int x , int y , int width, int length)


In which first two arguments are the x and y axis. Third argument is width and fourth argument
is height of the component.
Java has several predefined ​LayoutManager ​classes, several of which are described next. You
can use the layout manager that best fits your application.

FlowLayout:
FlowLayout ​is the default layout manager. This is the layout manager that the preceding examples have
used. ​FlowLayout ​implements a simple layout style, which is similar to how words flow in a text editor.
Components are laid out from the upper-left corner, left to right and top to bottom. When no more
components fit on a line, the next one appears on the next line. A small space is left between each
component, above and below, as well as left and right. Here are the constructors for ​FlowLayout​​:

FlowLayout( )
FlowLayout(int ​how)​
FlowLayout(int ​how,​ int ​horz​, int ​vert)​

The first form creates the default layout, which centers components and leaves five pixels of space
between each component. The second form lets you specify how each line is aligned. Valid values for
how a​ re as follows:

FlowLayout.LEFT
FlowLayout.CENTER
FlowLayout.RIGHT

These values specify left, center, and right alignment, respectively. The third form allows you to specify
the horizontal and vertical space left between components in ​horz a​ nd ​vert, ​respectively.

BorderLayout:
THE JAVA LIBRARY

The ​BorderLayout ​class implements a common layout style for top-level windows. It has four narrow,
fixed-width components at the edges and one large area in the center. The four sides are referred to as
north, south, east, and west. The middle area is called the center. Here are the constructors defined by
BorderLayout​​:
BorderLayout( )
BorderLayout(int ​horz,​ int ​vert​)

The first form creates a default border layout. The second allows you to specify the horizontal and
vertical space left between components in ​horz a​ nd ​vert, ​respectively. ​BorderLayout ​defines the
following constants that specify the regions:
BorderLayout.CENTER BorderLayout.SOUTH
BorderLayout.EAST BorderLayout.WEST
BorderLayout.NORTH

When adding components, you will use these constants with the following form of ​add( )​​, which is
defined by ​Container​​:

void add(Component ​compObj, ​Object ​region)​ ;

Here, ​compObj i​ s the component to be added, and ​region s​ pecifies where the component
will be added.

GridLayout:

GridLayout ​lays out components in a two-dimensional grid. When you instantiate a ​GridLayout​​, you
define the number of rows and columns. The constructors supported by ​GridLayout ​are shown here:

GridLayout( )
GridLayout(int ​numRows,​ int ​numColumns )​
GridLayout(int ​numRows,​ int ​numColumns,​ int ​horz,​ int ​vert)​
The first form creates a single-column grid layout. The second form creates a grid layout with the
specified number of rows and columns. The third form allows you to specify the horizontal and vertical
space left between components in ​horz ​and ​vert,​ respectively. Either ​numRows o​ r ​numColumns ​can be
zero. Specifying ​numRows ​as zero allows for unlimited-length columns. Specifying ​numColumns ​as zero
allows for unlimited-length rows.

Swings:

About Swings:

Swing is important to develop Java programs with a graphical user interface (GUI). There are many
components which are used for the building of GUI in Swing. The Swing Toolkit consists of many
components for the building of GUI. These components are also helpful in providing interactivity to
Java applications. Following are components which are included in Swing toolkit:

● list controls
● buttons
● labels
● tree controls
● table controls

All AWT flexible components can be handled by the Java Swing. Swing toolkit contains far more
components than the simple component toolkit. It is unique to any other toolkit in the way that it
supports integrated internationalization, a highly customizable text package, rich undo support etc. Not
only this you can also create your own look and feel using Swing other than the ones that are supported
by it. The customized look and feel can be created using Synth which is specially designed. Not to forget
that Swing also contains the basic user interface such as customizable painting, event handling, drag and
drop etc.
The Java Foundation Classes (JFC) which supports many more features important to a GUI program
comprises of Swing as well. The features which are supported by Java Foundation Classes (JFC) are the
ability to create a program that can work in different languages, the ability to add rich graphics
functionality etc.

There are several components contained in Swing toolkit such as check boxes, buttons, tables, text etc.
Some very simple components also provide sophisticated functionality. For instance, text fields provide
formatted text input or password field behavior. Furthermore, the file browsers and dialogs can be used
according to one's need and can even be customized.

Difference between Swings and AWT:

Swings AWT
Swings are the light weight components. AWTs are the heavy weight components.

Swings are developed by using pure java AWTs are developed by using C and C++.
language.

We can have different look and feel in swings. This feature is not available in awt.

Swing has many advanced features like JTabel, This are not available in awt.
JTabbedPane and JTree

Java Swing Class Hierarchy:


Swing Components:
All the components which are supported in AWT same components are also supported in Swings with a
slight change in their class name.
AWT Components Swing Components

Label JLabel

TextField JTextField

TextArea JTextArea

Choice JComboBox

Checkbox JCheckBox

List JList

Button JButton

- JRadioButton
- JPasswordField

- JTable

- JTree

- JTabbedPane

MenuBar JMenuBar

Menu JMenu

MenuItem JMenuItem

- JFileChooser

- JOptionPane

We will discuss only those components which are not discussed in AWT chapter.
JTabbedPane class:
The JTabbedPane container allows many panels to occupy the same area of the interface, and the user
may select which to show by clicking on a tab.
Constructor
JTabbedPane tp = new JTabbedPane();
Adding tabs to the JTabbedPane

Add tabs to a tabbed pane by calling ​addTab​ and passing it a String title and an instance of a class which
should be called when we pressed a tab. That class should be a subclass of JPanel.

addTab(“String”,instance);
Example program:
import javax.swing.*;

import java.awt.*;

public class TabbedPaneDemo extends JFrame

{
TabbedPaneDemo()

setLayout(new FlowLayout(FlowLayout.LEFT));

setTitle("Tabbed Demo");

setVisible(true);

setSize(500,500);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JTabbedPane pane = new JTabbedPane();

pane.addTab("Countries",new Count());

pane.addTab("Cities",new Cit());

add(pane);

public static void main(String a[])

new TabbedPaneDemo();

class Count extends JPanel

{
Count()

JButton b1 = new JButton("India");

JButton b2 = new JButton("SriLanka");

JButton b3 = new JButton("Australia");

add(b1);

add(b2);

add(b3);

class Cit extends JPanel

Cit()

JCheckBox cb1 = new JCheckBox("Hyderabad");

JCheckBox cb2 = new JCheckBox("Banglore");

JCheckBox cb3 = new JCheckBox("Pune");

add(cb1);

add(cb2);

add(cb3);
}

JMenuBar, JMenu, JMenuItem

A top-level window can have a menu bar associated with it. A menu bar displays a list of top-level menu
choices. Each choice is associated with a drop-down menu. This concept is implemented in Java by the
following classes: JMenuBar, JMenu, and JMenuItem. In general, a menu bar contains one or more
JMenu objects. Each JMenu object contains a list of JMenuItem objects. Each JMenuItem object
represents something that can be selected by the user. To create a menu bar, first create an instance of
JMenuBar. This class only defines the default constructor. Next, create instances of JMenu that will
define the selections displayed on the bar. Following are the constructors for Menu:

JMenu( )
JMenu(String ​optionName)​

Here, ​optionName s​ pecifies the name of the menu selection. The first form creates an empty menu.
Individual menu items are of type MenuItem. It defines these constructors:

JMenuItem( )
JMenuItem(String ​itemName​)

Here, ​itemName ​is the name shown in the menu.


4.4.3 JDBC

What is JDBC?
any relational database. One can write a single program using the JDBC API,and the JDBC is a Java
Api for executing SQL,Statements(As a point of interest JDBC is trademarked name and is not an
acronym; nevertheless,Jdbc is often thought of as standing for Java Database Connectivity. It
consists of a set of classes and interfaces written in the Java Programming language.JDBC provides
a standard API for tool/database developers and makes it possible to write database applications
using a pure Java API
Using JDBC, it is easy to send SQL statements to virtually program will be able to send SQL
.statements to the appropriate database. The Combination of Java and JDBC lets a programmer
writes it once and run it anywhere.

What Does JDBC Do?

Simply put,JDBC makes it possible to do three things

o Establish a connection with a database


o Send SQL statements
o Process the results
o JDBC Driver Types
o The JDBC drivers that we are aware of this time fit into one of four categories
o JDBC-ODBC Bridge plus ODBC driver
o Native-API party-java driver
o JDBC-Net pure java driver
o Native-protocol pure Java driver
An individual database system is accessed via a specific JDBC driver that implements the
java.sql.Driver interface. Drivers exist for nearly all-popular RDBMS systems, through few are
available for free. Sun bundles a free JDBC-ODBC bridge driver with the JDK to allow access to a
standard ODBC,data sources, such as a Microsoft Access database, Sun advises against using the
bridge driver for anything other than development and very limited development.

JDBC drivers are available for most database platforms, from a number of vendors and in a
number of different flavours. There are four driver categories
Type 01-JDBC-ODBC Bridge Driver

Type 01 drivers use a bridge technology to connect a java client to an ODBC database service.
Sun’s JDBC-ODBC bridge is the most common type 01 driver. These drivers implemented using
native code.

Type 02-Native-API party-java Driver

Type 02 drivers wrap a thin layer of java around database-specific native code libraries for
Oracle databases, the native code libraries might be based on the OCI(Oracle call Interface) libraries,
which were originally designed for ​c/c++ programmers, Because type-02 drivers are implemented
using native code. in some cases they have better performance than their all-java counter parts. They
add an element of risk, however, because a defect in a driver’s native code section can crash the
entire server

Type 03-Net-Protocol All-Java Driver

Type 03 drivers communicate via a generic network protocol to a piece of custom middleware. The
middleware component might use any type of driver to provide the actual database access. These
drivers are all java, which makes them useful for applet deployment and safe for servlet deployment

Type-04-native-protocol All-java Driver


Type o4 drivers are the most direct of the lot. Written entirely in java, Type 04 drivers understand
database-specific networking. protocols and can access the database directly without any additional
software

JDBC-ODBC Bridge
If possible use a Pure Java JDBC driver instead of the Bridge and an ODBC driver. This
completely eliminates the client configuration required by ODBC.It also eliminates the potential that
the Java VM could be corrupted by an error in the native code brought in by the Bridge(that is, the
Bridge native library, the ODBC driver manager library, library, the ODBC driver library, and the
database client library)

WHAT IS The JDBC-ODBE Bridge ?

The JDBC-ODBC Bridge is a Jdbc driver, which implements JDBC operations by translating them into
ODBC operations. To ODBC it appears as a normal application program. The Bridge is implemented as
the sun.jdbc.odbc Java package and contains a native library used to access ODBC.The Bridge is joint
development of Intersolv and Java Soft

4.4.4

​The database has become an integral part of almost every human's life. Without it, many things
we do would become very tedious, perhaps impossible tasks. Banks, universities, and libraries are three
examples of organizations that depend heavily on some sort of database system. On the Internet, search
engines, ​online shopping , and even the website naming convention (http://www...) would be
impossible without the use of a database. A database that is implemented and interfaced on a computer
is often termed a database server.

One of the fastest SQL (Structured Query Language) database servers currently on the market is the
MySQL server.MySQL, available for download, offers the database programmer with an array of
options and capabilities rarely seen in other database servers. What's more, MySQL is free of charge for
those wishing to use it for private and commercial use. Those wishing to develop applications
specifically using MySQL should consult ​MySQL's licensing section​, as there is a charge for licensing
the product.

These capabilities range across a number of topics, including the following:

● Ability to handle an unlimited number of simultaneous users.

● Capacity to handle 50,000,000+ records.

● Very fast command execution, perhaps the fastest to be found on the market.

● Easy and efficient user privilege system.

A database is really nothing more than a hierarchy of increasingly complex data structures. In MySQL,
the acknowledged structure for holding blocks (or ​records​​) of information is called the ​table​​.

These records, in turn, are made up of the smallest object that can be manipulated by the user, known as
the ​data type​​. Together, one or more of these data types form a record. A table holds the collection of
records that make up part of the database. We can consider the hierarchy of a database to be that of the
following:

Database < Table < Record < Datatype

Datatypes come in several forms and sizes, allowing the programmer to create tables suited for the scope
of the project. The decisions made in choosing proper datatypes greatly influence the performance of a
database, so it is wise to have a detailed understanding of these concepts.

MySQL Datatypes

MySQL is capable of many of the datatypes that even the novice programmer has probably already been
exposed to. Some of the more commonly used include:

CHAR (M)
CHAR's are used to represent fixed length strings. A CHAR string can range from 1-255 characters. In
later table creation, an example CHAR datatype would be declared as follows:

ex.
car_model CHAR(10);
VARCHAR (M)
VARCHAR is a more flexible form of the CHAR data type. It also represents data of type String, yet
stores this data in variable length format. Again, VARCHAR can hold 1-255 characters. VARCHAR is
usually a wiser choice than CHAR, due to it's variable length format characteristic. Although, keep in
mind that CHAR is much faster than VARCHAR, sometimes up to 50%.
(A CHAR stores the whole length of the declared variable, regardless of the size of the data contained
within, whereas a VARCHAR only stores the length of the data, thus reducing size of the database file.)

ex.
car_model VARCHAR(10);

INT (M) [Unsigned]


The INT datatype stores integers ranging from -2147483648 to 2147483647. An optional "unsigned"
can be denoted with the declaration, modifying the range to be 0 to 4294967295

ex.
light_years INT;
Valid integer: '-24567'. Invalid integer: '3000000000'.

ex.
light_years INT unsigned;
Valid integer: '3000000000'. Invalid integer: '-24567'.

FLOAT [(M,D)]
A FLOAT represents small decimal numbers, used when a somewhat more precise representation of a
number is required.

ex.
rainfall FLOAT (4,2);
This could be used to represent rainfall average in centimeters per year, which could be a decimal value.
More specifically, FLOAT (4,2) states the fact that rainfall can hold up to four characters and two
decimal places. Thus,

42.35 is valid, accurately represented.


324.45 is invalid, rounded to 324.5.
2.2 is valid, accurately represented.
34.542 is invalid, rounded to 34.54.

Note: Due to the fact that FLOAT is rounded, those wishing to represent money values would find it
​ ECIMAL​, a datatype found within MySQL that does not round values. Consult the
wise to use D
documentation for a complete explanation.

DATE

Stores date related information. The default format is 'YYYY-MM-DD', and ranges from '0000-00-00' to
'9999-12-31'. MySQL provides a powerful set of date formatting and manipulation commands, too
numerous to be covered within this article. However, one can find these functions covered in detail
within the MySQL documentation.

the_date DATE;

TEXT / BLOB
The text and blob datatypes are used when a string of 255 - 65535 characters is required to be stored.
This is useful when one would need to store an article such as the one you are reading. However, there is
no end space truncation as with VARCHAR AND CHAR. The only difference between BLOB and
TEXT is that TEXT is compared case insensitively, while BLOB is compared case sensitively.

SET
A datatype of type string that allows one to choose from a designated set of values, be it one value or
several values. One can designate up to 64 values.

ex.
transport SET ("truck", "wagon") NOT NULL;

From the above declaration, the following values can be held by transport:

""
"truck"
"wagon"
"truck,wagon"

ENUM
A datatype of type string that has the same characteristics as the SET datatype, but only one set of
allowed values may be chosen. Usually only takes up one byte of space, thus saving time and space
within a table.

ex.
transport ENUM ("truck", "wagon") NOT NULL;

From the above declaration, the following values can be held by transport:

""
"truck"
"wagon"

Records

Together, a group of declared datatypes form what is known as a record. A record can be as small as one
data variable, or as many as deemed needed. One or more records form the structure of a table.

The Bigger Picture: Tables

Before we can execute commands on the database, we must first create a table in which data can be
stored. This is accomplished in the following manner:

mysql> CREATE TABLE test (


> name VARCHAR (15),
> email VARCHAR (25),
> phone_number INT,
> ID INT NOT NULL AUTO_INCREMENT,
> PRIMARY KEY (ID));

Ensuing output:

Query OK, 0 rows affected (0.10 sec)


mysql>

The first table in your database has now been created. ​Note: no two tables can have the same name.
Note(2): Each dataspace is more often referred to as a c​ olumn.​

Column Characteristics:

● A name may not be made up of strictly numbers.

● A name may start with a number.


● A name may be up to 64 characters.

Other table options:

The following options can be placed after any datatype, adding other characteristics and capabilities to
them.

● Primary Key. Used to differentiate one record from another. No two records can have the same
primary key. This is obviously useful when it is imperative that no two records are mistaken to
be the other.

● Auto_Increment. A column with this function is automatically incremented one value (previous
+ 1) when an insertion is made into the record. The datatype is automatically incremented when
'NULL' is inserted into the column.

● NOT NULL. Signifies that the column can never be assigned a NULL value.

ex.
soc_sec_number INT PRIMARY KEY;
No two soc_sec_number records can hold the same value.

ID_NUMBER INT AUTO_INCREMENT;

Automatically increments in value, starting at '1', with every subsequent insertion.

Table-Relevant Commands

We can execute a number of useful commands pertaining to the tables, such as the following:

Show Tables

mysql> show tables;

Result:
This will list all tables currently existing within the database.

Show Columns

mysql> show columns from test;

Result:
This will return the columns and column information pertaining to the designated table.
Take a minute to execute each one of the above commands after you have created the test table. They
will prove very helpful as your database increases in size and complexity.

You should now have a basic understanding of the creation of tables, one of the most important concepts
of the MySQL server. You now know that tables are constructed using datatypes, which when grouped
together form a record. In the next section, we will begin learning how to manipulate the database. A
database can be manipulated in four possible ways: addition, deletion, modification, and search. These
topics will all be briefly covered in the following two sections. However, before we begin, I would like
to highlight the fact that SQL, like many computer languages, is somewhat particular about command
syntax. The slightest error in placement of a parentheses, comma, or semicolon will almost surely end in
error. As a result, take care to be attentive of command syntax.

Insertion of records

Note: The originally created table, test, created in the last section will be used to illustrate the examples
in this section. Here it is again, for quick reference:

mysql>​ CREATE TABLE test (


>​ name VARCHAR (15),
>​ email VARCHAR (25),
>​ phone_number INT,
>​ ID INT NOT NULL AUTO_INCREMENT,
>​ PRIMARY KEY (ID));

Insertion of data into the table is accomplished, logically enough, using the INSERT command.

mysql>​ INSERT INTO test VALUES


mysql>​ ('Bugs Bunny', 'carrots@devshed.com',
mysql>​ 5554321, NULL);
Result, assuming the command was correctly entered:

Query OK, 1 row affected (0.02 sec)


mysql>

So what happened?

● Single quotations were placed around the datatypes VARCHAR. All datatypes of type STRING
(i.e. char, varchar, text, blob, etc.) must be surrounded in single quotes, or an error will occur.

● There were no single quotes surrounding the phone number. Datatypes of type INT do not
require single quotes.

● NULL ? A NULL allows any datatype with the characteristic AUTO_INCREMENT to be


automatically assigned a value. If it is the first record inserted into the database, it is assigned the
value '1'. Otherwise, it is assigned the previously inserted value + 1 (i.e. if the previously inserted
value was '2', then the next would be '3'). In addition, the insertion of NULL into a variable of
type TIMESTAMP causes that variable to be given the value of the current date.

Note: It is of importance to remember that the same number of values must be inserted as datatypes are
contained within a record. In the above example, if one attempted to insert only three values instead of
four, the insertion would fail. The same result applies if one attempted to insert five values.

Example:

mysql>​ insert into test values('doggy');


ERROR 1058: Column count doesn't match value count
mysql>

Note (2): One of the advantageous aspects of MySQL is it's ability to convert without trouble between
datatypes. MySQL automatically converts between integers, strings, and dates without problems.
Selection

A database would not be much use if one was not able to search and extract data from it. In MySql
terms, this is accomplished through the SELECT statement.

mysql>​ SELECT * FROM test


mysql>​ WHERE (name = "Bugs Bunny");

Result:
name email phone ID

Bugs Bunny carrots@devshed.com 5554321 1

Let's assume we have inserted four differing records, all bearing the same name of "Bugs Bunny", yet
having different email addresses and phone numbers. The table test, would look somewhat like the
following:

name email phone ID

Bugs Bunny carrots@devshed.com 5554321 1

Bugs Bunny peppers@devshed.com 5554331 2

Bugs Bunny lettuce@devshed.com 5554341 3

Bugs Bunny celery@devshed.com 5554351 4

Deletion

One can also delete records inserted into the table. This is accomplished through the DELETE
command.

mysql>​ DELETE FROM test


mysql>​ WHERE (name = "Bugs Bunny");
Result:
This would result in the deletion of all records within the table test containing name "Bugs Bunny".

Another example:

mysql>​ DELETE FROM test


mysql>​ WHERE (phone_number = 5554321);

Result: (Using the previously illustrated example)

name email phone ID

Bugs Bunny peppers@devshed.com 5554331 2

Bugs Bunny lettuce@devshed.com 5554341 3

Bugs Bunny celery@devshed.com 5554351 4

Modification

MySQL also has the capability of modifying data already entered into the table. This is accomplished
through the UPDATE command.

mysql>​ UPDATE test SET name = 'Daffy Duck'


mysql>​ WHERE name = "Bugs Bunny";

name email phone ID

Daffy Duck peppers@devshed.com 5554331 2

Daffy Duck lettuce@devshed.com 5554341 3

Daffy Duck celery@devshed.com 5554351 4

This section, we covered the core ​MySQL database manipulation functions, basic insertion, deletion,
modification, and search. The next section will elaborate on these capabilities, providing extended
functioning and flexibility when manipulating the database.
What we have covered so far is but a small part of what MySQL is capable of. Let's delve a little deeper
into the language, exploring some of the more advanced commands of the language.

Logical Operations

MySQL includes full support of all basic logical operations.

AND (&&)

mysql>​ SELECT * FROM test WHERE


mysql>​ (name = "Bugs Bunny") AND
mysql>​ (phone_number = 5554321);

Result:
All records containing the name "Bugs Bunny" AND the phone number '5554321' will be displayed to
the screen.

OR ( || )

mysql>​ SELECT * FROM test WHERE


mysql>​ (name = "Bugs Bunny") OR
mysql>​ (phone_number = 5554321);

Result:
All records containing the name "Bugs Bunny" OR the phone number '5554321' will be displayed to the
screen.

NOT ( ! )

mysql>​ SELECT * FROM test WHERE


mysql>​ (name != "Bugs Bunny");
Result:
All records NOT containing the name "Bugs Bunny" will be displayed to the screen.

Order By

mysql>​ SELECT * FROM test WHERE


mysql>​ (name = "Bugs Bunny") ORDER BY
mysql>​ phone_number;

Result:
All records containing the name "Bugs Bunny" will be displayed to the screen, ordered in respect to the
phone_number.

Search functions

MySQL offers the user the ability to perform both general and specific searches on data.

mysql>​ SELECT * FROM test WHERE


mysql>​ (name LIKE "%gs Bunny");

Result:
All records containing the partial string "gs Bunny" will be displayed to the screen. This would include
such names as: "Bugs Bunny", "ags Bunny", "gs Bunny", and "234rtgs Bunny".

Notice that "LIKE" has been used instead of the equals sign (=). "LIKE" signifies that one is searching
for an estimate of the data requested, and not necessarily an exact copy.

The '%' sign could be placed anywhere within the string. The method in which the server searches for a
string is dependent upon where one places the '%' sign.
mysql>​ SELECT * FROM test WHERE
mysql>​ (name LIKE "Bugs Bunny%");

Result:
All records containing the partial string "Bugs Bunny" will be displayed to the screen. This would
include such names as: "Bugs Bunnys", "Bugs Bunnyyyy453", "Bugs Bunnytrtrtrtrtr", but not "gs
Bunny".

Focused Search Results

One can also perform searches and display only certain columns.

mysql>​ SELECT name FROM test WHERE


mysql>​ (name = "Bugs Bunny");

Result:

name

Bugs Bunny

Alter table

Another very important function of MySQL is the ability to modify previously created tables. This is
accomplished via the ALTER statement. This function allows one to add, modify, and delete columns,
as well as rename the table, among other functions.

Example: Rename the table

mysql>​ ALTER table test RENAME mytest;

Example: Add a column


mysql>​ ALTER table mytest ADD birthday DATE;

Example: Modify a column

mysql>​ ALTER table mytest CHANGE


mysql>​ name newname VARCHAR (25);

Example: Delete a column

mysql>​ ALTER table mytest DROP newname;

Executing the above four functions would modify test, creating the following table:

mysql>​ TABLE mytest (


>​ email VARCHAR (25),
>​ phone_number INT,
>​ ID INT AUTO_INCREMENT,
>​ birthday DATE );
DRIVER MANAGER AND DRIVER:

The java.sql package defines an interface called Java.sql.Driver that makes


to be implemented by all the JDBC drivers and a class called java.sql.DriverManager that acts as the
interface to the database clients for performing tasks like connecting to external resource managers, and
setting log streams. When a JDBC client requests the DriverManager to make a connection to an
external resource manager, it delegates the task to an approate driver class implemented by the JDBC
driver provided either by the resource manager vendor or a third party.

4.4.4 HTML
Hypertext Markup Language(HTML), the languages of the world wide web(WWW), allows users
to produces web pages that included text, graphics and pointer to other web pages (Hyperlinks).

HTML is not a programming language but it is an application of ISO Standard


8879,SGML(Standard Generalized Markup Language),but
Specialized to hypertext and adapted to the Web. The idea behind Hypertext one point to another
point. We can navigate through the information based on out interest and preference. A markup
language is simply a series of items enclosed within the elements should be displayed.
Hyperlinks are underlined or emphasized works that load to other documents or some portions of the
same document.
Html can be used to display any type of document on the host computer, which can be
geographically at a different location. It is a versatile language and can be used on any platform or
desktop

HTML provides tags(special codes) to make the document look attractive.

HTML provides are not case-sensitive. Using graphics,fonts,different sizes, color, etc.. can enhance
the presentation of the document. Anything
That is not a tag is part of the document it self.
Basic Html Tags​​:
<!-- --> Specific Comments.
<A>………</A> Creates Hypertext links.
<B>………</B> Creates hypertext links.
<Big>……..</Big> Formats text in large-font
<Body>…….</Body> contains all tags and text in the Html-document
<Center>……</Center> Creates Text
<DD>………..</DD> Definition of a term.
<TABLE>……</TABLE> creates table
<Td>………..</Td> indicates table data in a table.
<Tr>………..</Tr> designates a table row
<Th>……….</Th> creates a heading in a table.

ADVANTAGES:-

● A HTML document is small and hence easy to send over the net.It is small because it
does not include formatted information.
● HTML is platform independent
HTML tags are not case-sensitive.

4.4.6 JAVA SCRIPT

The Java Script Language

JavaScript is a compact , object-based scripting language for developing client and server internet
applications. Netscape Navigator 2.0 interprets JavaScript statements embedded directly in an
HTML page. and Livewire enables you to create server-based applications similar to common
gateway interface(cgi) programs.

In a client application for Navigator, JavaScript statements embedded in an HTML Page can
recognize and respond to user events such as mouse clicks form
Input, and page navigation.

For example, you can write a JavaScript function to verify that users enter valid information into a
form requesting a telephone number or zip code . Without any network transmission, an Html page
with embedded Java Script can interpret the entered text and alert the user with a message dialog if
the input is invalid or you can use JavaScript to perform an action (such as play an audio file,
execute an applet, or communicate with a plug-in) in response to the user opening or exiting a page.
1 INTRODUCTION
5.1 SYSTEM DESIGN

System design is transition from a user oriented document to programmers or data base personnel. The
design is a solution, how to approach to the creation of a new system. This is composed of several steps.
It provides the understanding and procedural details necessary for implementing the system
recommended in the feasibility study. Designing goes through logical and physical stages of
development, logical design reviews the present physical system, prepare input and output specification,
details of implementation plan and prepare a logical design walkthrough.

The database tables are designed by analyzing functions involved in the system and
format of the fields is also designed. The fields in the database tables should define their role in the
system. The unnecessary fields should be avoided because it affects the storage areas of the system.
Then in the input and output screen design, the design should be made user friendly. The menu should
be precise and compact.

5.2 UML DIAGRAMS

Unified Modeling Language​​:

The Unified Modeling Language allows the software engineer to express an analysis model using the
modeling notation that is governed by a set of syntactic semantic and pragmatic rules.
A UML system is represented using five different views that describe the system from distinctly
different perspective. Each view is defined by a set of diagram, which is as follows.
● User Model View
i. This view represents the system from the users perspective.
ii. The analysis representation describes a usage scenario from the end-users
perspective.

● Structural model view


i. In this model the data and functionality are arrived from inside the system.
ii. This model view models the static structures.

● Behavioral Model View


It represents the dynamic of behavioral as parts of the system, depicting the interactions
of collection between various structural elements described in the user model and
structural model view.

● Implementation Model View


In this the structural and behavioral as parts of the system are represented as they are to
be built.

● Environmental Model View

In this the structural and behavioral aspects of the environment in which the system is to
be implemented are represented.

UML is specifically constructed through two different domains they are:


✓ UML Analysis modeling, this focuses on the user model and structural model views of the
system.
✓ UML design modeling, which focuses on the behavioral modeling, implementation modeling
and environmental model views.

Use case Diagrams represent the functionality of the system from a user’s point of view. Use cases are
used during requirements elicitation and analysis to represent the functionality of the system. Use cases
focus on the behavior of the system from external point of view.

Actors are external entities that interact with the system. Examples of actors include users like
administrator, bank customer …etc., or another system like central database.
5.3 NORMALIZATION

A Database is a collection of interrelated data stored with a minimum of redundancy to serve many
applications. The database design is used to group data into a number of tables and minimizes the
artificiality embedded in using separate files. The tables are organized to:

● Reduced duplication of data.


● Simplify functions like adding, deleting, modifying data etc..,
● Retrieving data
● Clarity and ease of use
● More information at low cost

Normalization

Normalization is built around the concept of normal forms. A relation is said to be in a


particular normal form if it satisfies a certain specified set of constraints on the kind of functional
dependencies that could be associated with the relation. The normal forms are used to ensure that
various types of anomalies and inconsistencies are not introduced into the database.

First Normal Form:

A relation R is in first normal form if and only if all underlying domains contained
atomic values only.

Second Normal Form:


A relation R is said to be in second normal form if and only if it is in first normal form
and every non-key attribute is fully dependent on the primary key.

Third Normal Form:


A relation R is said to be in third normal form if and only if it is in second normal form
and every non key attribute is non transitively depend on the primary key.

5.4 DATA DICTIONARY

create database tpa;

use tpa;

create table filemetadata(filename varchar(25),lastmod int(25),length int(25));

create table login(user varchar(20),pwd varchar(25));

create table modified(user varchar(25),msg varchar(100));

create table userfile(user varchar(20),filename varchar(80));


7.1 INTRODUCTION TO TESTING

Introduction to Testing:

Testing is a process, which reveals errors in the program. It is the major quality measure employed
during software development. During software development. During testing, the program is executed
with a set of test cases and the output of the program for the test cases is evaluated to determine if the
program is performing as it is expected to perform.

7.2 TESTING IN STRATEGIES

In order to make sure that the system does not have errors, the different levels of testing
strategies that are applied at differing phases of software development are:

Unit Testing:
Unit Testing is done on individual modules as they are completed and become executable. It is
confined only to the designer's requirements.

Each module can be tested using the following two Strategies:

Black Box Testing:


In this strategy some test cases are generated as input conditions that fully execute all
functional requirements for the program. This testing has been uses to find errors in the following
categories:

● Incorrect or missing functions


● Interface errors
● Errors in data structure or external database access
● Performance errors
● Initialization and termination errors.
In this testing only the output is checked for correctness.
The logical flow of the data is not checked.

White Box testing :

In this the test cases are generated on the logic of each module by drawing flow graphs of that
module and logical decisions are tested on all the cases. It has been uses to generate the test cases in
the following cases:

✓ Guarantee that all independent paths have been Executed.


✓ Execute all logical decisions on their true and false Sides.
✓ Execute all loops at their boundaries and within their operational bounds
✓ Execute internal data structures to ensure their validity.
Integrating Testing :
Integration testing ensures that software and subsystems work together a whole. It tests the
interface of all the modules to make sure that the modules behave properly when integrated
together.

System Testing:
Involves in-house testing of the entire system before delivery to the user. It's aim is to satisfy the
user the system meets all requirements of the client's specifications.
Acceptance Testing :
It is a pre-delivery testing in which entire system is tested at client's site on real world data to find
errors.

Test Approach :
Testing can be done in two ways:

● Bottom up approach
● Top down approach
Bottom up Approach:
Testing can be performed starting from smallest and lowest level modules and proceeding
one at a time. For each module in bottom up testing a short program executes the module and
provides the needed data so that the module is asked to perform the way it will when embedded with
in the larger system. When bottom level modules are tested attention turns to those on the next level
that use the lower level ones they are tested individually and then linked with the previously
examined lower level modules.

Top down approach:

This type of testing starts from upper level modules. Since the detailed activities usually
performed in the lower level routines are not provided stubs are written. A stub is a module shell
called by upper level module and that when reached properly will return a message to the calling
module indicating that proper interaction occurred. No attempt is made to verify the correctness of
the lower level module.

Validation:
The system has been tested and implemented successfully and thus ensured that all the requirements
as listed in the software requirements specification are completely fulfilled. In case of erroneous
input corresponding error messages are displayed
8.1 INTRODUCTION

System Security:

Setting Up Authentication for Web Applications

Introduction:
To configure authentication for a Web Application, use the <login-config> element of the web.xml
deployment descriptor. In this element you define the security realm containing the user credentials, the
method of authentication, and the location of resources for authentication.

8.2 SECURITY IN SOFTWARE

To set up authentication for Web Applications:

1. Open the web.xml deployment descriptor in a text editor or use the Administration Console.
Specify the authentication method using the <auth-method> element. The available options are:
BASIC
Basic authentication uses the Web Browser to display a username/password dialog box. This
username and password is authenticated against the realm.
FORM
Form-based authentication requires that you return an HTML form containing the username and
password. The fields returned from the form elements must be: j_username and j_password, and
the action attribute must be j_security_check. Here is an example of the HTML coding for using
FORM authentication:
<form method="POST" action="j_security_check">
<input type="text" name="j_username">
<input type="password" name="j_password">
</form>
The resource used to generate the HTML form may be an HTML page, a JSP, or a servlet. You
define this resource with the <form-login-page> element.

The HTTP session object is created when the login page is served. Therefore, the session.isNew
() method returns FALSE when called from pages served after successful authentication.
9. BIBLIOGRAPHY

References for the Project Development Were Taken From the following Books and Web Sites.

JAVA Technologies

JAVA Complete Reference

Java Script Programming by Yehuda Shiran

Mastering JAVA Security

JAVA2 Networking by Pistoria

JAVA Security by Scotl oaks

Head First EJB Sierra Bates

J2EE Professional by Shadab siddiqui

JAVA server pages by Larne Pekowsley


JAVA Server pages by Nick Todd

HTML

HTML Black Book by Holzner

JDBC

Java Database Programming with JDBC by Patel moss.


Software Engineering by Roger Pressman

You might also like