Upload
vishnu-suresh
View
326
Download
2
Embed Size (px)
DESCRIPTION
Citation preview
ACKNOWLEDGEMENTS
We are greatly indebted to all those who have rendered help for
successful completion of this project. We express our deep- sense of gratitude and
sincere thanks to our principal Mr. P.V.Sugathan who had provided the necessary
facilities to do our project.
We are also very thankful to Mrs. Nisha Rose , Head of the
Computer Science & Engineering Department, and Mrs. Sumija, our tutor, Mrs.
Sajna, our project guide for her master guidance, intelligent suggestions and
patient effort that paved the way for our successful completion of this project.
We express our heartfelt gratitude to IPCS s/w Ltd. (Calicut) for
providing us the facilities. Above all we are indebted to the Lord Almighty for
giving us the courage and strength.
ABSTRACT
Many sophisticated computer applications could be significantly
simplified if they are built on top of a general-purpose distributed database
management system. In spite of much research on distributed database management
systems there are only a few homogenous distributed database system architectures,
that have reached the development stage. The situation with heterogeneous
multidatabase systems, which connect a number of possibly incompatible pre-existing
database systems, is even less satisfactory.
HetrogeniousDatabase Management System (DDMS) is specially
developed for Heterogeneous Database Platforms. ‘Distributed Database
Management System’ focus mainly on heterogeneous distributed data management.
It is a system for managing databases stored on multiple computers in a network.
List of Figures
Figure 8.1 Login page..................................................................................................64
Figure 8.2 Single table import.....................................................................................64
Figure 8.3 Single Export..............................................................................................65
Figure 8.4 Query Analyzer..........................................................................................65
Figure 8.5 Multiple Export..........................................................................................66
Figure 8.6 Multiple Import..........................................................................................66
Figure 8.7 Setting Privillages.......................................................................................67
Table of contents
Acknowledgements……………………………………………………….………iii
Abstract……………………………………………………………………………iv
List of Figures………………………………………………………………….....vi
1. Introduction..............................................................................................................7
1.1 OBJECTIVE........................................................................................................7
2. SYSTEM STUDY...................................................................................................8
2.1 EXISTING SYSTEM..........................................................................................8
2.2 Proposed System..................................................................................................8
3. SYSTEM REQUIREMENTS...............................................................................10
3.1 HARDWARE REQUIREMENTS....................................................................10
3.2 Software Specification.......................................................................................10
3.3 SOFTWARE DESCRIPTION...........................................................................10
4.MODULES IN SOFTWARE.................................................................................25
4.1HDMS ADMINISTRATOR...............................................................................25
4.2 HDMS CLIENT.................................................................................................26
5. DATA FLOW DIAGRAM....................................................................................28
5.1 LEVEL 0 DFD...................................................................................................29
5.2 LEVEL 1 DFD query analyzer..........................................................................30
5.3 LEVEL 1 DFD TABLE EXPORT....................................................................31
5.4 LEVEL 1 DFD TABLE IMPORT.....................................................................32
5.4 LEVEL 2 DFD...................................................................................................33
6. CODING.................................................................................................................34
6.1 MAIN FUNCTIONS.........................................................................................34
6.2 QUERY ANALYZER.......................................................................................43
6.3 IMPORTING TABLES.....................................................................................49
6.4 EXPORTING TABLES.....................................................................................60
7. DESIGN AND IMPLEMENTATION.................................................................70
7.1 INPUT DESIGN................................................................................................70
7.2 COMPONENT DESIGN...................................................................................70
7.3 OUTPUT DESIGN............................................................................................70
7.4 DATABASE DESIGN......................................................................................71
8. SCREENSHOTS....................................................................................................72
9. SYSTEM TESTING..............................................................................................76
10. CONCLUSION....................................................................................................77
Cost Estimation Report.............................................................................................78
REFERENCES..........................................................................................................79
HDBMS
1. Introduction
Many sophisticated computer applications could be significantly
simplified if they are built on top of a general-purpose distributed database
management system. In spite of much research on distributed database management
systems there are only a few homogenous distributed database system architectures,
that have reached the development stage. The situation with heterogeneous
multidatabase systems, which connect a number of possibly incompatible pre-existing
database systems, is even less satisfactory.
HetrogeniousDatabase Management System (HDMS) is specially
developed for Heterogeneous Database Platforms. ‘Distributed Database
Management System’ focus mainly on heterogeneous distributed data management.
It is a system for managing databases stored on multiple computers in a network.
A distributed database is a set of databases stored on multiple
computers that typically appears to applications as a single database. Consequently,
an application can simultaneously access and modify the data in several databases in
a network. Distributed Database management System is a software system that
manages a distributed database while making the distribution transparent to the user.
1.1 OBJECTIVE
It is increasingly important for organizations to achieve additional
coordination of diverse computerized operations. To do so, it is necessary to have
database systems that can operate over a distributed network and can encompass a
heterogeneous mix of computers, operating systems, communications links, and local
database management systems.
A distributed database is a set of databases stored on multiple computers that
typically appears to applications as a single database. Consequently, an application
can simultaneously access and modify the data in several databases in a network.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 6
HDBMS
Distributed Database management System is a software system that manages a
distributed database while making the distribution transparent to the user.
2. SYSTEM STUDY
2.1 EXISTING SYSTEM
Think of an enterprise of (say) more than 100 computers that act as database clients.
If there is only one database server, then all the queries sent by these clients have to
be answered by the same single server. This will lead to severe traffic congestion at
the server and also in the network.
It is common in an enterprise to have many departments. Each of these departments
will need access to a common database used throughout in the Enterprise. However
the majority of data requirements of each of these departments will be department
specific.
2.1.1 LIMITATIONS OF EXISTING SYSTEM
1. Does not support heterogeneous databases.
2. Difficulty in managing distributed data.
2.2 Proposed System
The proposed system to develop a software for Distributed database system
in the Diverse database management systems are used in large organizations. The
heterogeneous distributed database system can provide a flexible integration of
diverse databases for users and applications. This is because it allows for retrieval
and update of distributed data under different data systems giving the illusion of
accessing a single centralized database system.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 7
HDBMS
2.2.1 ADVANTAGES OF PROPOSED SYSTEM
Supports heterogeneous database applications.
Suitable in Linux, Windows or any other platform.
Better management of distributed data.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 8
HDBMS
3. SYSTEM REQUIREMENTS
3.1 HARDWARE REQUIREMENTS
A recommended configuration is follows
Micro Processor : Pentium IV 2.6 GHz
CPU Clock : 512 MHz
System Bus : 32 Bits
Ram : 512 MB
Hard Disk Capacity : 80 GB
Floppy Disk : 144 KB
VDU : SVGA
Keyboard : Standard 108 Keys
Mouse : Serial 3 Button, Logitech
Monitor : SVGA Color
3.2 Software Specification
Operating system. : Linux /Windows XP/ Windows 2000/Windows 98
Front end. : Java-J2EE
Back end. : MS-ACCESS, SQL, and Oracle
3.3 SOFTWARE DESCRIPTION
3.3.1 FRONTEND SOFTWARE
Java Soft, an operating company of Sun Microsystems, spent years developing a
high-powered programming language for the ‘90s and beyond. Java delivers on this
promise by being the most robust, easy-to-use, and versatile programming language
available today. It includes the best aspects of earlier programming languages such as
C and C++, allows you to create powerful applications, has features such as built-in
multimedia capabilities that make creating multimedia presentations easier than ever,
and leaves out those things we all hated about C and C++ like multiple inheritance,
operator overloading, and pointers.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 9
HDBMS
The best news about Java is that it is object oriented and architecture neutral.
The promise of object-oriented programming (OOP) is the capability to reuse code.
But, as C++ programmers will tell you, good intentions do not mean a whole lot when
it comes to reuse of C++ code. With Java, on the other hand, you can realize the
benefits of code reuse immediately.
You no longer have to develop separate applications for different platforms.
With Java, you can develop a single application that is immediately usable on
multiple platforms. Imagine the countless hours you will save by being able to
develop a single application usable on Windows, UNIX, and Macintosh systems.
For the entrepreneur or individual programmer, Java’s platform independence
allows you to develop powerful applications for operating systems you may never
have worked with. This means that if you own a software-development or Internet-
related business, whether it is a one-person operation or a conglomerate, you will be
able to reach new customers and new markets. In an age when everyone is looking at
the bottom line, a technology that allows you to sell more, do more, and reach larger
audiences (potentially everyone who owns a computer) is certainly something worth
investigating.
Furthermore, by allowing you to use the programming environment you are
the most comfortable with, Java empowers you, the programmer. This is true whether
you have limited technical skills or expert knowledge of computers. If you have a
working knowledge of another programming language, you will find that Java is
surprisingly easy to learn.
The developers of Java thought very carefully about the structure of their new
language and by no mere coincidence modeled Java after C and C++. C is a favorite
language for programmers doing procedural programming. C++ is a favorite language
for programmers writing object-oriented programs. C and C++ have user and
developer bases many times greater than their nearest competitors and could, in fact,
be considered to be their own best competition.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 10
HDBMS
Therefore, to ensure that Java is easy to understand and use, Java is modeled
after C and C++. Java also borrows extensions from Objective C. These extensions
allow for extremely dynamic method resolution. This makes it very easy for current
C, Objective C, and C++ developers to transition to Java.
Any programmer who has ever had problems with pointers and memory
management should rush to embrace Java with open arms. Java gets rid of pointers,
automatically manages memory for you, and even features a garbage-collection
routine that runs in the background.
In distributed environments, such as the World Wide Web, strict security
mechanisms are essential-businesses simply cannot risk compromising their systems.
The developers of the Java programming language knew this. They developed Java to
be the most secure programming environment you will find anywhere. Java doesn’t
just fix security loopholes-it eliminates them, which makes Java the perfect language
for programming on the Web.
Pointers are the biggest security problem with C/C++ programs. System
crackers can use seemingly benign programs to forge pointers to memory, steal
information from your system, and crash your system permanently. In Java, you can’t
forge pointers to memory because there are no pointers. Java eliminates many other
security loopholes as well. For example, when Java programs are compiled and run,
they are checked with a dynamic code verifier to ensure that the program has no
malicious coding. Additionally, the Java runtime environment provides strict rules for
programs started from remote hosts. These programs cannot access the local network,
cannot access files on your local system, and cannot start programs on your systems
either.
Programming with Java
Java is first and foremost an object-oriented programming language.
Many programmers are surprised when they discover how easy it is to follow sound
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 11
HDBMS
object-oriented design practices with Java. The following sections give you a better
understanding of what Java offers.
Java’s magic: the byte code
Byte code is a highly optimized set of instructions designed to be
executed by the Java run-time system, which is called the Java Virtual Machine
(JVM). In its standard form, JVM is an interpreter for Byte code.
When a Java program is compiled using the “javac” command, the
complier generates a class file, which is also known as the Byte code. This Byte code
is then fed into the JVM, which consists of a Compiler, Byte Code Verifier and an
Interpreter embedded in it. The Byte code passes through all of these and finally the
JVM generates the output.
SYSTEM
BYTE CODE FORMATION OF JAVA
JAVA FEATURES
The inventors of java wanted to design a language, which
could offer solutions to some of the problems encountered in modern programming.
They wanted the language to not only be reliable, portable and distributed but also
simple, compact and interactive. Sun Microsystems officially describes Java with the
following attributes:
Compiled and Interpreted
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 12
.class files JAVA VIRTUAL MACHINE (JVM)
Javac filename
COMPILER COMPILERBYTE CODE
INTERPRETER
HDBMS
Usually a computer language is either compiled or interpreted. Java
combines both these approaches thus making Java a two-stage system. First, Java
compiler translates source code into what is known as byte code instructions. Byte
codes are not machine instructions and therefore, in the second stage, Java interpreter
generates machine code that can be directly executed by the machine that is running
the Java program.
Platform-independent and portable
The most significant contribution of Java over other languages is its
portability. Java programs can be easily moved from the one computer system to
another, anywhere and anytime. Changes and upgrade in operating systems,
processors and system resources not will force any changes in Java programs. This is
the reason why Java has become a popular language for programming on Internet,
which interconnects different kinds of systems worldwide. We can download, a Java
applet from a remote computer onto our local system via Internet and execute it
locally. This makes the Internet an extension of the user’s basic system providing
practically unlimited number of accessible applets and applications.
Java ensures portability in two ways. First, Java compiler generates
byte code instructions that can be implemented on any machine. Secondly, the sizes
of the primitive data types are machine-independent.
Object-oriented
Java is a true object-oriented language. Almost every time in Java is an
object. All program code and data reside within objects and classes. Java comes with
an extensive of classes, arranged in packages, which we can use in our programs by
inheritance. The object model in Java is simple and easy to extend.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 13
HDBMS
Robust and secure
Java is a robust language. It provides many safeguards to ensure
reliable code. It has strict compile time and run time checking for data types. It is
designed as a garbage-collected language relieving the programmers virtually all
memory management problems. Java also incorporates the concept of exception
handling, which captures series errors and eliminates any risk of crashing the system.
Security becomes an important issue for a language that is used for
programming on Internet. Threat of viruses and abuse of resources is everywhere.
Java systems not only verify all memory access but also ensure that no viruses are
communicated with an applet. The absence of pointers in Java ensures that programs
cannot gain access to memory locations without proper authorization.
Distributed
Java is designed as a distributed language for creating applications on
networks. It has the ability to share both data and programs. Java applications can
open and access remote objects on Internet as easily as they can do in a local system.
This enables multiple programming at multiple remote locations to collaborate and
work together on a single project.
Simple, small and familiar
Java is a small and simple language. Many features of C and C++ that
are either redundant or sources of unreliable code are not part of Java. Thus Java does
not use pointers, preprocessor header files, go to statement and many others. It also
eliminates operator overloading and multiple inheritance. Familiarity is another
striking feature of Java. To make the language look familiar to the existing
programmers, it was modeled on C and C++ languages. Java uses many constructs of
C and C++ and therefore, Java code “looks like a C++” code. In fact, Java is a
simplified version of C++.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 14
HDBMS
Multithreaded and interactive
Multithreaded means handling multiple tasks simultaneously. Java
supports multithreaded programs. This means that we need not wait for the
application to finish, one task before beginning another. For example, we can listen to
an audio clip while scrolling a page and at the same time download as applet from a
distant computer. This feature greatly improves the interactive performance of
graphical applications.
The Java runtime comes with tools that support multiprocess
synchronization and construct smoothly running interactive systems.
High performance
Java performance is impressive for an interpreted language, mainly
due to the user of intermediate byte code. According to Sun, Java speed is comparable
to the native C/C++. Java architecture is also designed to reduce overheads during
runtime. Further, the incorporation of multithreading enhances the overall execution
speed of the Java programs.
Dynamic and Extensible
Java is a dynamic language. Java is capable of dynamic linking in new
class libraries, methods, and objects. Java also determines the type of the class
through a query, making it possible to either dynamically link or abort the program,
depending on the response.
Java programs support functions written in other languages such as C
and C++. These functions are known as native methods. This facility enables the
programmers to use the efficient function available in these languages. Native
methods are linked dynamically at runtime
JFC (Java Foundation Class)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 15
HDBMS
JFC contains 5 major technologies namely Swing, Abstract Window
Toolkit (AWT), Accessibility, Drag and Drop and 2D Graphics .All the technologies,
except, Drag and Drop and Accessibility API have been used in this project.
We shall see a brief sketch of all of these.
Accessibility API
Assistive technologies (or systems) are useful for disabled people who
need additional help to use the user interface. The assistive systems include screen
readers, screen magnifiers and speech recognition systems. The Accessibility API
provides an interface that allows assistive technologies to interact and communicate
with JFC and AWT components.
Abstract Window Toolkit (AWT)
The AWT is not new to Java Programmers. The AWT is the
cornerstone for the JFC itself and is one of the core libraries that were launched with
JDK1.0.In fact; the AWT lays foundation for the Swing components. While you can
create the user interface with Swing components, you still need to use the layout
managers and event models supported in AWT
2D Graphics
The API in the AWT supports graphics to some extent in Java
programming. However, as the Java technology started maturing, the necessity to
incorporate a more sophisticated graphics API was recognized. The 2D Graphics API
can support advanced 2D graphics and imaging
Drag and drop
With native platform-capable drag-and-drop, a user with a native
application sitting next to a java application will be able to drag-and-drop between the
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 16
HDBMS
java and native applications. The level of precision in the user gesture (drag
movement) will be consistent with that of the host native platform.
Java Swings
Swing development has it roots in the Model-View-Controller (MVC)
architecture. The MVC-based architecture allows Swing components to be replaced
with different data models and views. The pluggable look-and-feel is the result of the
MVC architecture. Because Java is a platform-independent language and runs on any
client machine, you should be able to harness the look-and-feel of just about any
platform.
SWING FEATURES AND CONCEPTS
Swing components and the containment hierarchy
Swing provides many standard GUI components such as buttons, lists,
menus, and text areas, which you combine to create your program’s GUI. It also
includes containers such as windows and tool bars.
Layout management
Containers use layout managers to determine the size and position of
the components they contain. Borders affect the layout of Swing GUIs by making
Swing components larger. You can also use invisible components to affect layout.
Event handling
Event handling is how programs respond to external events, such as
the user pressing a mouse button. Swing programs perform all their painting and
event handling in the event-dispatching thread.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 17
HDBMS
Painting
Painting means drawing the component on-screen. Although it’s easy
to customize a component’s painting, most programs don’t do anything more
complicated than customizing a component’s border.
Threads and swing
If you do something to a visible component that might depend on or affect its state,
then you need to do it from the event-dispatching thread. This isn’t an issue for many
simple programs, which generally refer to components only in event-handling code.
However, other programs need to use the invoke Later method to execute component-
related calls in the event-dispatching thread.
Pluggable Look-and-Feel
This feature enables the user to switch the look-and-feel of Swing
components without restarting the application. The Swing library supports a cross-
platform look-and-feel – that remains the same across all platforms wherever the
program runs. The native look-and-feel is native to whatever particular system that
the program happens to be running, including Windows and Motif. The Swing library
provides an API that gives great flexibility in determining the look-and-feel of
applications. It also enables you to create your own look-and-feel
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 18
HDBMS
Swing Architecture
Swing is built on the base of the AWT classes., but not on the AWT
UI component classes. Where there are equivalent classes in each toolkit for a
particular UI component, the swing version should be used.
Packages
The Swing component toolkit consists of over 250 pure Java classes
and 75 interfaces contained in more than 10 packages. It is used to build lightweight
and user interface.
Swing consists of non-user interface (non-UI) classes as well as more
familiar user-interface (UI) classes. They do not display anything on screen.
Examples of non UI Swing classes are the events fired by Swing components and the
Swing data model classes. The UI classes such as buttons and labels create visible
components that applications can display on screen, and they can be combined to
create a complete graphical user interface. The Swing UI components descend from
the J-component class, and all begin with the capital letter J
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 19
JFC
Swing
AWT
Java 2D
Drag and Drop
Accessibility
Application Code
HDBMS
The Swing component classes are given below.
Class Description
AbstractButton Abstract superclass for Swing
buttons
Button group Encapsulates a mutually exclusive
set of buttons
ImageIcon Encapsulates an icon
JApplet The Swing version of APPLET
JButton The Swing push button class
JCheckBox The Swing check box class
JComboBox Encapsulates a combo box
JLabel The Swing version of a label
JRadioButton The Swing version of a button
JScrollPane Encapsulates a scrollable window
JTabbed pane Encapsulates a tabbed window
JTable Encapsulates a table-based control
JTextField The Swing version of a text field
JTree Encapsulates a tree-based control
Basics of Networking
In its most basic form, a computer network is simply two computers that
communicate with each other. Of course, most networks consist of more than two
computers. But the principles of network communication are the same for two, three
or even thousand computers.
Networks usually fall into one of the two groups: local area networks and
wide area networks. A local area network (LAN) connects computers located near
each other.
In contrast, wide area networks (WANs) consist if computers in different
cities, states or even countries. When we connect two or more computers so that they
can communicate, we form a network. And when we connect two or more networks
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 20
HDBMS
we form an Internet work or Internet. The Internet is the largest and most widely
known Inter network in the world.
To perform data transfers, networks use communication switching.
Communication switching lets hardware devices share physical lines of
communication. The two common methods of communication switching are circuit
switching and packet switching.
Circuit switching creates a single unbroken path between two devices that
want to communicate. While these devices talk, no other devices can use this path.
However when the two devices finish talking, they release the communication path so
that other devices can use it.
Most modern networks, including the Internet use packet switching. In fact,
we can refer to the Internet as a packet-switched network. In a packet switched
network, programs break data into pieces called packets and transmit them between
many computers. Data can travel in both directions. As such each packet must carry
its destination address.
Servers and Clients
The whole point of a network is to allow two machines to connect and
communicate with each other. In client server applications, the server provides some
service, such as file transfer, processing database queries etc. The client uses the
service provided by the server, by displaying the results to the user. The
communication that occurs between the client and the server must be reliable. That is,
no data can be dropped and must arrive on the client side in the same order, in which
the server sent it.
TCP provides a reliable, point-to-point communication channel that the
client-server applications on the Internet use to communicate with each other. To
communicate over TCP, a client program and a server program establish a connection
to one another. Each socket binds a socket to its end of the connection. To
communicate, the client and the server each reads from and writes to the socket
bound to the connection.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 21
HDBMS
A Network Server Class
In the socket networking model, the server side has to read from or
write to many sockets that are connected to many clients. Threading on the server
side has an additional benefit: by having a thread associated with each client, we no
longer need to worry about other clients within any single thread. This simplifies our
server-side programming: we can code our classes as if we were handling a single
client at a time..
The server-side socket setup is implemented in two steps. First, a
socket is used for the purpose of listening on a port known to the client. The client
connects to this port as a means to negotiate a private connection to the server.
Network connections between clients and server
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 22
HDBMS
Once a data connection has been negotiated, the server
and client then communicate through this private connection. In general, this process
is generic: most programmers are concerned with the data sockets (the private
connection). Furthermore, the data sockets on the server side are usually self
contained to a particular client. While it is possible to have different mechanisms that
deal with many data sockets at the same time, generally the same code is used to deal
with each of the data sockets independently of the other data sockets.
Since the setup is generic, we can place it into a generic TCPServer
class and not have to implement the generic code again. Basically, this TCPServer
class creates a ServerSocket and accepts connection requests from clients. This is
done in a separate thread. Once a connection is made, the server clones (makes a copy
of) itself so that it may handle the new client connection in a new thread.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 23
HDBMS
4.MODULES IN SOFTWARE
4.1HDMS ADMINISTRATOR
Recording Server DSN details
Details of the DSNs in the server are stored .Details include name,type of
DSN.Only these DSNs are exported and imported by the client.
Change Administrator password
This option helps the administrator for changing his password frequently. It is
recommended by us to change the password frequently for increasing the
of the system.
Registering new users
Administrator register new users.They will be given permission to access the
software.
Change User passwords
This option helps the administrator for changing users password.It is necessary
to change the password frequently for increasing the security of the system.
View ,Edit User profile
Administrator can view users profile and can change the details if required.
Delete User
Administrator deletes particular user if required.
Handling User Complaints
Administrator deals with open complaints and closed complaints.Closed
complaints are given by registered user,for example ,if they cannot execute
some queries etc.Open complaints are given by users who are not
registered ,like cannot login etc.
Setting User Permissions
Allow the administrator to view and set the permissions for the user.
Read Only -Users who have read Only access to the databases.
Read and Write -Users who have read and write access to the databases.
All -Users who are having all permissions. That is he can perform any type of
operations on a database.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 24
HDBMS
View users currently logged in.
Show the list of all the users, who are currently logged in to the system.
4.2 HDMS CLIENT
Login
The way by which, only the authorized users are allowed to access the
system. It
checks the username and password from the table and allows only authorized
users inside. Login check is having a major role in this system, since security
is a consideration as all databases are open in front of the user. This has a direct
interaction with administrator since he is the one who has to monitor what are the
permissions of a particular user. The processing is done; the username and
password is checked from the database and if the check is successful then the user
is allowed in.
Query Analyzer
The query analyzer is the feature that allows the user to execute any type of
query he/she wants. The solid responsibility of this component is to allow any
type of query the user executes. The query should be according to the standard
format of the query, and then only the execution will be proper. This is the main
part of the application since getting the result for any type query is what the user
need. The user will be able to select the dsn and the table from a combo box
provided and can get the fields of the table too.This feature need the resources
like DSN and table lists which should be provided by the data manager with
accordance to the permission he is set with.The user gives the query, the
permission is checked and if it is ok then the query will be executed and the
output is given.
Export Tables
The tables from the local machine is transferred to the server and hence to the
any other local systems. It should allow the export of any table in any database to
the server whenever the user wants. This exporting will be only possible if the
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 25
HDBMS
user is having permissions for it. This is used for transferring the table to the
server machine. Perfect GUI is provided so the whole process will look simple in
the users point of view. The user will select the table to export, also he/she can do
it in two ways, one, only the skeleton of the table is exported and in the other both
the skeleton and data are exported.
Import Tables
The tables from the server machine are transferred to the local machine. It
should allow the import of any table in any database to the server whenever the
user wants. This importing will be only possible if the user is having permissions
for it. This is used for getting the table from the server machine. Perfect GUI is
provided so the whole process will look simple in the users point of view. The
user will select the table to import, also he/she can do it in two ways, one, only the
skeleton of the table is imported and in the other both the skeleton and the data are
imported.
Database Conversion
This facilitates conversion of one database to another.For example we can
convert a MS ACCESS database to Oracle and so on.
Change passwords,view profile
This option helps the user for changing his/her password. It is
recommended by us to change the password frequently for increasing the security
of the system.User can also view his profile.
Posting Complaints
Give the user an extra support for clearing his doubts. If there is a doubt for
the user he can type his doubt in the Complaint Box, and press the send button.
The complaint will be send to the server and the solution for that complaint will
be send back by the server.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 26
HDBMS
5. DATA FLOW DIAGRAM
Understand the data flow in a system in a neat diagrammatic manner.
There are standard symbols to draw DFD. Some of the important symbols that we use are:
External Entity: This denotes the external entity of a considered system. These are
those entities to the software system and interact with the system by in putting data to
the system or consuming data produced by the system.
Process: This denotes a particular process in the system.
Data Store: This denotes a database or any type of data store in a system. This is
needed when our system stores some information in a database.
Output: This denotes the output from the system
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 27
HDBMS
Data Flow: The headed arrow represents the data flow in a system. This is normally
labeled to show what data is flowing from one process to another.
Figure illustrates the data flow in a REAL TIME NETWORK MONITORING
SYSTEM.
5.1 LEVEL 0 DFD
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 28
Distributed DatabaseManagement System
Client (1) (2) ;
Data Manager(Server)
Query
Response
Updates data
Gets requests
Looking for data
Retrieving data
Data store
HDBMS
5.2 LEVEL 1 DFD query analyzer
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 29
Client
Query analyzer
Identifying where the table is- server or client
Analyzing and retrieving result from the client database
Analyzing and retrieving result from the server database
Client database
Server database
Table name and type of database
Query
Query
Query
Query
Query
Data
Data
Giving result for the query from the server
Result from client
HDBMS
5.3 LEVEL 1 DFD TABLE EXPORT
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 30
Client
Identifying to which database the table has to be exported
Getting the table and columns to export
Client database
Server database
Messages
Data
Looking for data Retrieving
the data
Sending the data
Details tot
Server response
Table name and data Insertion
response
Data inserting
Response
Inserting the data into the specified database
Server activity
HDBMS
5.4 LEVEL 1 DFD TABLE IMPORT
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 31
Client
Specifies the database, table, fields to server
Checks the database and returns data
Importing Table
Table name
DB and table name
DB and table name
Data
Data
Data to be stored
Client database
DB where particular table is found
Data being stored in the corresponding database
Data to database
Server
Looking for table
Retrieving data
HDBMS
5.4 LEVEL 2 DFD
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 32
Client
Server
Login check
Server processClient
process
Export tables
Import tables Change
databaseQuery analyzer
New user creation
Client login database
Server login file
Client db
Server database
Username and password
Password
Looking for entry
Looking for entry
Result
Login success
Table details
To the server database
Checking for entry
Retrieving result
Into the database
Query
Query
Result
Query
User details
Into the database
HDBMS
6. CODING
6.1 MAIN FUNCTIONS
import java.io.*;import java.rmi.*;import java.rmi.server.*;import java.sql.*;import java.util.*;import javax.swing.*;import javax.swing.table.DefaultTableModel;import javax.swing.table.TableModel;import java.sql.ResultSetMetaData;import java.util.Vector;
class imple extends UnicastRemoteObject implements inter
{imple() throws RemoteException
{
} public boolean login(String user,String pass,String ip) throws RemoteException
{ System.out.println("User Name and Pass is "+user+pass);
try
{FileOutputStream f=new FileOutputStream("userlist.txt",true);
f.write((ip+"\n").getBytes());f.close();Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection
con=DriverManager.getConnection("jdbc:odbc:proj");Statement smt=con.createStatement();String qry;qry="select user,pass from user where
user='"+user+"'and pass='"+pass+"'";System.out.println(qry);ResultSet rs=smt.executeQuery(qry);
while (rs.next()){
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 33
HDBMS
System.out.println("login sucessfull"); return(true);
}
}
catch(Exception c){
System.out.println(c);}return(false);}
public String[] getIp() throws RemoteException{ String s="";
String ips[]=new String[10];int i=0;
try
{ FileReader ff=new FileReader("userlist.txt");
BufferedReader rd=new BufferedReader(ff);s=rd.readLine();ips[i]=s;
while (s!=null){
i++;
System.out.println(s);s=rd.readLine();ips[i]=s;
}ff.close();
}
catch(Exception ex){
System.out.println(ex);}return(ips);}
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 34
HDBMS
public String[] getDSN()throws RemoteException{
String s1="";String gdsn[]=new String[50];int j=0;
try{
Runtime r=Runtime.getRuntime();Process pr=r.exec("dsn.exe");FileReader f=new FileReader("DSN.txt");BufferedReader b=new BufferedReader(f);
s1= b.readLine();s1=s1.replace("\"","");
gdsn[j]=s1;while (s1!=null){
j++;System.out.println(s1);s1=b.readLine();if (s1.startsWith("\"")){
break;}gdsn[j]=s1;
}f.close();
}catch(Exception exc){
System.out.println(exc);}return(gdsn);
}
public String[] getTables(String dsn) throws RemoteException{
String str;String gt[]=new String[40];System.out.println("DSN IS....... "+dsn);int m=0;try{
System.out.println("DSN IS in block"+dsn);
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 35
HDBMS
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");System.out.println("DSN IS in block"+dsn);
Connection con=DriverManager.getConnection("jdbc:odbc:"+dsn);
System.out.println("DSN IS in block"+dsn);DatabaseMetaData dm=con.getMetaData();
int i=0;ResultSet rs=dm.getTables(null,null,null,new String[]
{"TABLE"});while (rs.next()){
str=rs.getString(3);gt[i]=str;
i++;}
}catch(Exception e){
System.out.println("Error at getTables :Error "+e);}return(gt);
}public Vector[] importtable(String dsn,String table){
Vector v[]=new Vector[2];v[0]=new Vector();v[1]=new Vector();try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection
con=DriverManager.getConnection("jdbc:odbc:"+dsn);Statement s=con.createStatement();ResultSet rs=s.executeQuery("select * from "+table);ResultSetMetaData rm=rs.getMetaData();int colcount=rm.getColumnCount();int flag[]=new int[colcount];
String cname,ctype,str="";int csize;for(int i=1;i<=colcount;i++)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 36
HDBMS
{cname=rm.getColumnName(i);ctype=rm.getColumnTypeName(i);csize=rm.getColumnDisplaySize(i);if(cname.equalsIgnoreCase("user")){cname="user1";}
if (!ctype.equalsIgnoreCase("INTEGER")){
str=cname+" "+ctype+" "+"("+csize+")";}else{
str=cname+" "+ctype;}
v[0].addElement(str);str="";
}
String st="";rs.close();rs=s.executeQuery("select * from "+table);while (rs.next()){
for(int j=1;j<=colcount;j++){st=st+"'"+rs.getString(j)+"'"+",";}st=st.substring(0,st.lastIndexOf(","));System.out.println(st);v[1].addElement(st);st="";
}
}catch(Exception im){
System.out.println("In get table datas"+im);}return v;
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 37
HDBMS
}
public JTable QueryAnalyzer(String dsn,String table,String Query)
{JTable t;String st;int l;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection
con=DriverManager.getConnection("jdbc:odbc:"+dsn);Statement s=con.createStatement();ResultSet rs;l=Query.indexOf(" ");st=Query.substring(0,l);System.out.println(st);if (!st.equalsIgnoreCase("select")){s.executeUpdate(Query);}con.close();Connection
conn=DriverManager.getConnection("jdbc:odbc:"+dsn);Statement stt=conn.createStatement();rs=stt.executeQuery("select * from "+table);ResultSetMetaData metaData=rs.getMetaData();int numberOfColumns = metaData.getColumnCount();
Vector columnNames = new Vector();
for(int column = 0; column < numberOfColumns; column++)
{ columnNames.addElement(metaData.getColumnLabel(column + 1)); }
Vector rows = new Vector();
while (rs.next()) {
Vector newRow = new Vector();
for(int i = 1; i <= numberOfColumns; i++)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 38
HDBMS
{ newRow.addElement(rs.getObject(i)); }
rows.addElement(newRow); }
DefaultTableModel m=new DefaultTableModel(rows, columnNames);
t= new JTable(m);
return(t);}
catch (Exception e) {
t=new JTable(); e.printStackTrace();
return(t); }
}
//logout
public boolean exit(String ip) throws RemoteException{ String s;
String ips[]=new String[20];String ips1[]=new String[20];
try
{ FileReader rd=new FileReader("userlist.txt");BufferedReader b=new BufferedReader(rd);s=b.readLine();int i=0;while (s!=null){
//System.out.println(s);
ips[i]=s;s=b.readLine();i++;
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 39
HDBMS
}//String ip="192.168.10.16";int x=0;for(int j=0;j<i;j++){
s=ips[j];
if (s.equals(ip)){
continue;
}System.out.println(s);ips1[x]=s;x++;
}FileOutputStream out=new FileOutputStream("userlist.txt");for(int j=0;j<x;j++){
out.write((ips1[j]+"\n").getBytes());}
return(true);}
catch(Exception ex){System.out.println(ex);return(false);}
}
//export table
public boolean exporttable(String dsn,String table,Vector[] v){
String ss=""; try {
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 40
HDBMS
for(int i=0;i<v[0].size();i++) { ss=ss+v[0].elementAt(i)+",";
} Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:"+dsn); Statement s=con.createStatement(); ss=ss.substring(0,ss.lastIndexOf(",")); if (table.equalsIgnoreCase("user")) { table="user1"; } ss="create table "+table+"("+ss+")"; System.out.println(ss); s.executeUpdate(ss); String qry; for(int i=0;i<v[1].size();i++) { qry="insert into "+table+" values("; qry=qry+v[1].elementAt(i)+")";
System.out.println(qry);s.executeUpdate(qry);
} } catch(Exception ex) {System.out.println(ex+"here in exporttab"); }return(true); } public boolean update(String user,String data) { try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:proj"); Statement s=con.createStatement();
s.executeUpdate("update user set priv='"+data+"'where user='"+user+"'"); JOptionPane.showMessageDialog(null," User Database Updated
","DDBMS",1); return(true);
// System.out.println("gh");
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 41
HDBMS
}catch(Exception e){
System.out.println(e);return(false);
} }
}
6.2 QUERY ANALYZER
import java.rmi.*;import java.io.*;import javax.swing.*;import java.util.*;import java.awt.event.*;import java.sql.*;import java.net.*;import javax.swing.table.TableModel;
class queryanalyzer implements ActionListener,ItemListener{
JFrame frame;JLabel lb1;JLabel lb2;JLabel lb3;JLabel lb4;JLabel lb5;JComboBox cb1;JComboBox cb2;JComboBox cb3;JComboBox cb4;JTextField tf;JButton b1;JButton b2;JPanel pan;JTable tab;JFrame fr;JPanel pp;JScrollPane JSP;
queryanalyzer(String ser)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 42
HDBMS
{frame=new JFrame("QueryAnalyzer");pan=new JPanel();pan.setLayout(null);
lb1=new JLabel("Remote system");lb1.setBounds(15,20,100,60);pan.add(lb1);
cb1=new JComboBox();cb1.setBounds(130,40,150,20);pan.add(cb1);
lb2=new JLabel("Remote DSN");lb2.setBounds(15,80,100,20);pan.add(lb2);
cb2=new JComboBox();cb2.setBounds(130,80,150,20);pan.add(cb2);
lb3=new JLabel("Remote Table");lb3.setBounds(15,120,200,20);pan.add(lb3);
cb3=new JComboBox();cb3.setBounds(130,120,150,20);pan.add(cb3);
lb4=new JLabel("Query");lb4.setBounds(550,10,120,60);pan.add(lb4);
tf=new JTextField();tf.setBounds(300,60,480,30);pan.add(tf);
b1=new JButton("Execute");b1.setBounds(400,105,120,30);pan.add(b1);
b2=new JButton("Cancel");b2.setBounds(580,105,120,30);pan.add(b2);
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 43
HDBMS
frame.add(pan);frame.setBounds(150,50,800,380);
//frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setResizable(false);
frame.show();
fr=new JFrame("Table"); pp=new JPanel();
pp.setLayout(null);
cb1.addItemListener(this);cb2.addItemListener(this);b1.addActionListener(this);b2.addActionListener(this);try
{inter i=(inter)Naming.lookup("rmi://"+ser+"/register");String ips[];ips=new String[20];
ips=i.getIp();int j=0;while (ips[j]!=null){
cb1.addItem(ips[j++]);
}}catch(Exception e){
System.out.println(e);}
try{
String s1; Runtime r=Runtime.getRuntime(); Process pr=r.exec("dsn.exe");
FileReader f=new FileReader("DSN.txt");BufferedReader b=new BufferedReader(f);
s1= b.readLine();s1.trim();
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 44
HDBMS
int pos; pos=s1.indexOf("\"");
s1=s1.substring(pos+1,s1.length());
while (s1!=null){
cb4.addItem(s1); s1=b.readLine();
if(s1.equals("\"")){break;}
}f.close();
}catch(Exception ab){
System.out.println(ab);}
}
public void itemStateChanged(ItemEvent ie){
if (ie.getSource()==cb1){
cb2.removeAllItems();String s1;String gdsn[];gdsn=new String[20];try{inter g=(inter)Naming.lookup("rmi://"+cb1.getSelectedItem()
+"/register");gdsn=g.getDSN();int k=0;s1=gdsn[k];s1.trim();int pos;
pos=s1.indexOf("\"");s1=s1.substring(pos+1,s1.length());
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 45
HDBMS
while (s1!=null){
cb2.addItem(s1);k++;s1=gdsn[k];if(s1.equals("\"")){break;}
}}catch(Exception a){
System.out.println(a);}
}
if (ie.getSource()==cb2){ cb3.removeAllItems();
String s2;String gt[];gt=new String[25];
try{
inter t=(inter)Naming.lookup("rmi://"+cb1.getSelectedItem()+"/register");
String dsn;dsn=""+cb2.getSelectedItem();dsn.trim();int p;p=dsn.indexOf("(");dsn=dsn.substring(0,p-1);System.out.println("This is the "+dsn) ;gt=t.getTables(dsn);int m=0;s2=gt[m];while (s2!=null){
cb3.addItem(s2);m++;s2=gt[m];
}
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 46
HDBMS
}catch(Exception ab){
System.out.println(ab+"efgf");}
}}
public void actionPerformed(ActionEvent e){
if (e.getSource()==b1) { String dsn,table,Query;
JTable tb; tb=new JTable();
table=""+cb3.getSelectedItem();Query=tf.getText();
dsn=""+cb2.getSelectedItem();dsn.trim();int p;p=dsn.indexOf("(");dsn=dsn.substring(0,p-1);
try{
inter t=(inter)Naming.lookup("rmi://"+cb1.getSelectedItem()+"/register");
tb=t.QueryAnalyzer(dsn,table,Query);
fr.setBounds(300,150,310,310);
JSP=new JScrollPane(tb);JSP.setBounds(10,10,290,290);pp.add(JSP);fr.add(pp);fr.setVisible(true);
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 47
HDBMS
frame.dispose();
}catch(Exception n){
System.out.println(n+"error1");}
}
if (e.getSource()==b2) { frame.show(); }
}
}
6.3 IMPORTING TABLES
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.rmi.*;
import java.util.*;
import java.sql.*;
class exports implements ActionListener,ItemListener
{
JFrame frame;
JLabel lb1;
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 48
HDBMS
JLabel lb2;
JLabel lb3;
JLabel lb4;
JComboBox cb1;
JComboBox cb2;
JComboBox cb3;
JComboBox cb4;
JButton b1;
JButton b2;
JList list;
String ser;
exports(String ser1)
{
ser=ser1;
frame=new JFrame("Export");
JPanel pan=new JPanel();
pan.setLayout(null);
lb1=new JLabel("Remote System");
lb1.setBounds(15,20,100,60);
pan.add(lb1);
cb1=new JComboBox();
cb1.setBounds(130,40,150,20);
pan.add(cb1);
lb2=new JLabel(" Remote DSN");
lb2.setBounds(15,80,100,20);
pan.add(lb2);
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 49
HDBMS
cb2=new JComboBox();
cb2.setBounds(130,80,150,20);
pan.add(cb2);
lb3=new JLabel("DSN");
lb3.setBounds(15,155,200,20);
pan.add(lb3);
cb3=new JComboBox();
cb3.setBounds(130,155,150,20);
pan.add(cb3);
lb4=new JLabel("Table");
lb4.setBounds(15,185,100,60);
pan.add(lb4);
cb4=new JComboBox();
cb4.setBounds(130,200,150,20);
pan.add(cb4);
b1=new JButton("Export");
b1.setBounds(100,280,80,30);
pan.add(b1);
b2=new JButton("Cancel");
b2.setBounds(200,280,80,30);
pan.add(b2);
frame.add(pan);
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 50
HDBMS
frame.setBounds(300,50,500,420);
frame.show();
b1.addActionListener(this);
cb1.addItemListener(this);
cb3.addItemListener(this);
b2.addActionListener(this);
try
{
inter i=(inter)Naming.lookup("rmi://"+ser+"/register");
String ips[];
ips=new String[20];
ips=i.getIp();
int j=0;
while (ips[j]!=null)
{
cb1.addItem(ips[j++]);
}
}
catch(Exception e)
{
System.out.println(e);
}
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 51
HDBMS
try
{
String s1;
Runtime r=Runtime.getRuntime();
Process pr=r.exec("dsn.exe");
FileReader f=new FileReader("DSN.txt");
BufferedReader b=new BufferedReader(f);
s1= b.readLine();
s1.trim();
int pos;
pos=s1.indexOf("\"");
s1=s1.substring(pos+1,s1.length());
while (s1!=null)
{
cb3.addItem(s1);
s1=b.readLine();
if(s1.equals("\""))
{
break;
}
}
f.close();
}
catch(Exception ab)
{
System.out.println(ab);
}
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 52
HDBMS
}
public void itemStateChanged(ItemEvent ie)
{
if (ie.getSource()==cb1)
{
cb2.removeAllItems();
String s1;
String gdsn[];
gdsn=new String[20];
try
{
inter g=(inter)Naming.lookup("rmi://"+cb1.getSelectedItem()
+"/register");
gdsn=g.getDSN();
int k=0;
s1=gdsn[k];
s1.trim();
int pos;
pos=s1.indexOf("\"");
s1=s1.substring(pos+1,s1.length());
while (s1!=null)
{
cb2.addItem(s1);
k++;
s1=gdsn[k];
if(s1.equals("\""))
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 53
HDBMS
{
break;
}
}
}
catch(Exception a)
{
System.out.println(a);
}
}
if (ie.getSource()==cb3)
{
cb4.removeAllItems();
String s2;
String gt[];
gt=new String[25];
try
{
String dsn,str;
dsn=""+cb3.getSelectedItem();
dsn.trim();
int p;
p=dsn.indexOf("(");
dsn=dsn.substring(0,p-1);
System.out.println("This is the "+dsn);
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 54
HDBMS
Connection
con=DriverManager.getConnection("jdbc:odbc:"+dsn);
System.out.println("DSN IS in block"+dsn);
DatabaseMetaData dm=con.getMetaData();
int i=0;
ResultSet rs=dm.getTables(null,null,null,new String[]
{"TABLE"});
while (rs.next())
{
str=rs.getString(3);
gt[i]=str;
i++;
}
int m=0;
s2=gt[m];
while (s2!=null)
{
cb4.addItem(s2);
m++;
s2=gt[m];
}
}
catch(Exception ab)
{
System.out.println(ab);
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 55
HDBMS
}
}
}
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource()==b2)
{
frame.dispose();
}
if (ae.getSource()==b1)
{
String dsn,table;
try
{
dsn=""+cb3.getSelectedItem();
dsn.trim();
dsn=dsn.substring(0,dsn.indexOf("(")-1);
table=""+cb4.getSelectedItem();
Vector v[]=new Vector[2];
v[0]=new Vector();
v[1]=new Vector();
inter
in=(inter)Naming.lookup("rmi://"+cb1.getSelectedItem()+"/register");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 56
HDBMS
Connection
con=DriverManager.getConnection("jdbc:odbc:"+dsn);
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select * from "+table);
ResultSetMetaData rm=rs.getMetaData();
int colcount=rm.getColumnCount();
int flag[]=new int[colcount];
String cname,ctype,str="";
int csize;
for(int i=1;i<=colcount;i++)
{
cname=rm.getColumnName(i);
ctype=rm.getColumnTypeName(i);
csize=rm.getColumnDisplaySize(i);
if(cname.equalsIgnoreCase("user"))
{
cname="user1";
}
if (!ctype.equalsIgnoreCase("INTEGER"))
{
str=cname+" "+ctype+" "+"("+csize+")";
}
else
{
str=cname+" "+ctype;
}
v[0].addElement(str);
str="";
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 57
HDBMS
}
String st="";
rs.close();
rs=s.executeQuery("select * from "+table);
while (rs.next())
{
for(int j=1;j<=colcount;j++)
{
st=st+"'"+rs.getString(j)+"'"+",";
}
st=st.substring(0,st.lastIndexOf(","));
System.out.println(st);
v[1].addElement(st);
st="";
}
boolean b;String ds;
ds=""+cb2.getSelectedItem();
ds.trim();
ds=ds.substring(0,ds.indexOf("(")-1);
b=in.exporttable(ds,table,v);
if (b)
{
JOptionPane.showMessageDialog(null," Table Exported","DDBMS",1);
}
else
{
JOptionPane.showMessageDialog(null," Faildd to Export");
}
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 58
HDBMS
}
catch(Exception exe)
{
System.out.println(exe);
}
}
}
}
6.4 EXPORTING TABLES
import java.rmi.*;
import java.io.*;
import javax.swing.*;
import java.util.*;
import java.awt.event.*;
import java.sql.*;
class imports implements ItemListener,ActionListener
{
JFrame frame;
JLabel lb1;
JLabel lb2;
JLabel lb3;
JLabel lb4;
JLabel lb5;
JComboBox cb1;
JComboBox cb2;
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 59
HDBMS
JComboBox cb3;
JComboBox cb4;
JTextField tf;
JButton b1;
JButton b2;
imports(String ser)
{
frame=new JFrame("Import");
JPanel pan=new JPanel();
pan.setLayout(null);
lb1=new JLabel("Remote system");
lb1.setBounds(15,20,100,60);
pan.add(lb1);
cb1=new JComboBox();
cb1.setBounds(130,40,150,20);
pan.add(cb1);
lb2=new JLabel("Remote DSN");
lb2.setBounds(15,80,100,20);
pan.add(lb2);
cb2=new JComboBox();
cb2.setBounds(130,80,150,20);
pan.add(cb2);
lb3=new JLabel("Remote Table");
lb3.setBounds(15,120,200,20);
pan.add(lb3);
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 60
HDBMS
cb3=new JComboBox();
cb3.setBounds(130,120,150,20);
pan.add(cb3);
lb4=new JLabel("DSN");
lb4.setBounds(15,185,100,60);
pan.add(lb4);
cb4=new JComboBox();
cb4.setBounds(130,200,150,20);
pan.add(cb4);
lb5=new JLabel("Table");
lb5.setBounds(15,220,100,60);
pan.add(lb5);
tf=new JTextField();
tf.setBounds(130,240,150,20);
pan.add(tf);
b1=new JButton("Import");
b1.setBounds(70,300,80,30);
pan.add(b1);
b2=new JButton("Cancel");
b2.setBounds(170,300,80,30);
pan.add(b2);
frame.add(pan);
frame.setBounds(400,50,330,380);
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 61
HDBMS
frame.show();
cb1.addItemListener(this);
cb2.addItemListener(this);
b1.addActionListener(this);
b2.addActionListener(this);
try
{
inter i=(inter)Naming.lookup("rmi://"+ser+"/register");
String ips[];
ips=new String[20];
ips=i.getIp();
int j=0;
while (ips[j]!=null)
{
cb1.addItem(ips[j++]);
}
}
catch(Exception e)
{
System.out.println(e);
}
try
{
String s1;
Runtime r=Runtime.getRuntime();
Process pr=r.exec("dsn.exe");
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 62
HDBMS
FileReader f=new FileReader("DSN.txt");
BufferedReader b=new BufferedReader(f);
s1= b.readLine();
s1.trim();
int pos;
pos=s1.indexOf("\"");
s1=s1.substring(pos+1,s1.length());
while (s1!=null)
{
cb4.addItem(s1);
s1=b.readLine();
if(s1.equals("\""))
{
break;
}
}
f.close();
}
catch(Exception ab)
{
System.out.println(ab);
}
}
public void itemStateChanged(ItemEvent ie)
{
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 63
HDBMS
if (ie.getSource()==cb1)
{
cb2.removeAllItems();
String s1;
String gdsn[];
gdsn=new String[20];
try
{
inter g=(inter)Naming.lookup("rmi://"+cb1.getSelectedItem()
+"/register");
gdsn=g.getDSN();
int k=0;
s1=gdsn[k];
s1.trim();
int pos;
pos=s1.indexOf("\"");
s1=s1.substring(pos+1,s1.length());
while (s1!=null)
{
cb2.addItem(s1);
k++;
s1=gdsn[k];
if(s1.equals("\""))
{
break;
}
}
}
catch(Exception a)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 64
HDBMS
{
System.out.println(a);
}
}
if (ie.getSource()==cb2)
{
cb3.removeAllItems();
String s2;
String gt[];
gt=new String[25];
try
{
inter t=(inter)Naming.lookup("rmi://"+cb1.getSelectedItem()
+"/register");
String dsn;
dsn=""+cb2.getSelectedItem();
dsn.trim();
int p;
p=dsn.indexOf("(");
dsn=dsn.substring(0,p-1);
System.out.println("This is the "+dsn) ;
gt=t.getTables(dsn);
int m=0;
s2=gt[m];
while (s2!=null)
{
cb3.addItem(s2);
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 65
HDBMS
m++;
s2=gt[m];
}
}
catch(Exception ab)
{
System.out.println(ab+"efgf");
}
}
}
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource()==b2)
{
frame.dispose();
}
if (ae.getSource()==b1)
{
String dsn,table,ss="";
try
{dsn=""+cb2.getSelectedItem();
dsn.trim();
dsn=dsn.substring(0,dsn.indexOf("(")-1);
table=""+cb3.getSelectedItem();
inter in=(inter)Naming.lookup("rmi://"+cb1.getSelectedItem()+"/register");
Vector v[]=new Vector[2];
v[0]=new Vector();
v[1]=new Vector();
v=in.importtable(dsn,table);
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 66
HDBMS
for(int i=0;i<v[0].size();i++)
{
ss=ss+v[0].elementAt(i)+",";
}
String tab,ds;
ds=""+cb4.getSelectedItem();
ds.trim();
ds=ds.substring(0,ds.indexOf("(")-1);
tab=tf.getText();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:"+ds);
Statement s=con.createStatement();
ss=ss.substring(0,ss.lastIndexOf(","));
ss="create table "+tab+"("+ss+")";
System.out.println(ss);
s.executeUpdate(ss);
//s.close();
String qry;
for(int i=0;i<v[1].size();i++)
{
qry="insert into "+tab+" values(";
qry=qry+v[1].elementAt(i)+")";
System.out.println(qry);
s.executeUpdate(qry);
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 67
HDBMS
}
JOptionPane.showMessageDialog(null," Table imported","DDBMS",1);
}
catch(Exception ex)
{System.out.println(ex+"here in import");
}
}
}
}
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 68
HDBMS
7. DESIGN AND IMPLEMENTATION
7.1 INPUT DESIGN
Input design is the process of converting user inputs into computer-based
format. Input data is collected and organized into groups of similar data. The goal
behind designing input data is to make the data entry easy and make it free from
logical errors. Example: The input entry to all type of clients is the user name and
password. If they are valid the client is allowed to enter into the software.
OBJECTIVES To achieve the highest possible level of accuracy.
To ensure that the input is acceptable and understandable.
7.2 COMPONENT DESIGN
The different types of components that come under this application are:
1. Login
2. Query Analyzer
3. Export Table
4. Import Table
7.3 OUTPUT DESIGN
Outputs are the most important and direct source of information to the user.
Efficient and eligible output design should improve the system’s relationship with the
user and help in decision making. Output design generally deals with the results
generated by the system. In this system the correct answers for the queries in the most
appropriate format. ie, to show the output of the select query in the table format and
that of an insert or create in a text area.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 69
HDBMS
7.4 DATABASE DESIGN
The general theme behind a database is to handle information as an integrated
whole. A database is a collection of interrelated data stored with minimum
redundancy to serve many users quickly and efficiently. The general objective is to
make information access easy, quick, inexpensive and flexible for the user. The
concept behind a database is an integrated collection of data and provides a
centralized access to the data from the program. While designing database, several
objectives must be considered:
Controlled Redundancy
Data Independence
More information at low cost
Accuracy and Integrity
Privacy and Security.
Performance
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 70
HDBMS
8. SCREENSHOTS
Figure 8.1 Login page
Figure 8.2 Single table import
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 71
HDBMS
Figure 8.3 Single Export
Figure 8.4 Query Analyzer
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 72
HDBMS
Figure 8.5 Multiple Export
Figure 8.6 Multiple Import
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 73
HDBMS
Figure 8.7 Setting Privillages
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 74
HDBMS
9. SYSTEM TESTING
Software test is a critical element of software quality assurance and represents
the ultimate review specification, design and coding. System testing makes a
logical assumption that all of the parts of the system are correct; goal will be
successfully achieved.
Testing objectives
1. Testing is a process of executing a program with the aim of finding an error.
2. A good test case is one that has a high probability of finding an error that is
not yet discovered.
3. A successful test is one that uncovers an error that is not yet discovered.
Unit Testing
Unit Testing focuses on verification efforts on the smallest unit of software
design of the module. This is also known as 'Module Testing'. This testing was
carried out during programming stage itself. In this step each module is found to
be working satisfactorily as regards to expected output from the module.
Integration Testing
Integration Testing is a systematic testing for constructing the program
structure, while at the same time conducting tests to uncover the errors associated
with the interface. The objective is to take the tested unit module and build a
program structure. All the modules are combined and listed as a whole. Here
corrections are difficult because the vastness of the program complicates the
isolation of cause, thus in the integration step, all the errors uncovered are
corrected for the next testing step.
Validation Testing
Validation succeeds when the software functions in a manner that can be
reasonably expected by the customer.
Output Testing
No system will be useful if it does not produce the user required output in the
specified format. The output generated while the system was under construction is
compared with the format suggested by the user.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 75
HDBMS
10. CONCLUSION
It is the end of this project. Though we cannot say it is a perfect
system worth out bugs and errors, we tried our level best for minimizing errors and
making the system more user friendly for the purpose. The project “HDBMS” after
being tested and was found to be achieving what is meant for. But this system never
provides in the user point of view. The system is found to be 100% error free and
ready for implementation.
The System is much flexible and extensible and hence further
enhancements, If needed, can be developed and it can be integrated with the existing
one easily .
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, January 2011 76
HDBMS
Cost Estimation Report
(In Rs.)
Requirement Analysis & Specifications – 1240
Design – 2480
Languages & Tools - 4216
Coding & Unit Testing – 1984
Integration & system Testing - 4960
Maintenance - 9920
---------------
24800/-
Total Amount = 24800/- (Twenty four thousand four hundred rupees only)
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING, January 2011 77
HDBMS
REFERENCES
[1] Elias M Awad Systems Analysis and Design - Second Edition
[2] Roger s Pressman Software Engineering - Second Edition
[3] Kathy Sierra & Bert Bates Head First Java
[4] Herbert Schildt Java Programming Complete Reference
[5] Gagan Java Programming beginners book
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING, January 2011 78