Академический Документы
Профессиональный Документы
Культура Документы
K.L.Rajitha(09mcmt01) Coding
P.Manasa(09mcmt05) Design
P.Suhasini(09mcmt10) Front End
D.Lavanya(09mcmt15) Coding
M.Sai Sudheer(09mcmt24) Requirements Specification
B.Manasa(09mcmt29) DataBase Creation
Contents:
Acknowledgement
Abstract
Introduction
Requirements Specifications
Design
Modules
Database Design
Front End
Database Connectivity With Java
IDE
UML Diagrams
Use Case Diagrams
Class Diagrams
Sequence Diagrams
Component Diagrams
Deployment Diagrams
Implementation
Coding
Testing
Results
Screen Shots
Conclusion
Future Scope
References
ACKNOWLEDGMENT
SOFTWARE REQUIREMENTS:
HARDWARE REQUIREMENTS:
MODULES:
DATABASE DESIGN:
1. TRAINRESRVATION TABLE
2. PASSENGER TABLE
The most common operation in SQL is the query, which is performed with the
declarative SELECT statement. SELECT retrieves data from one or more tables, or
expressions.
• The FROM clause which indicates the table(s) from which data is to be retrieved.
The FROM clause can include optional JOIN subclauses to specify the rules for
joining tables.
• The WHERE clause includes a comparison predicate, which restricts the rows
returned by the query. The WHERE clause eliminates all rows from the result set
for which the comparison predicate does not evaluate to True.
The following is an example of a SELECT query that returns a list of trains available. The
query retrieves all rows from the trainreservation in which the sourcr column contains a
value as lingampally. The asterisk (*) in the select list indicates that all columns of the
trainreservation table should be included in the result set.
Data manipulation
The Data Manipulation Language (DML) is the subset of SQL used to add, update and
delete data:
Transaction controls
• ROLLBACK causes all data changes since the last COMMIT or ROLLBACK to
be discarded, leaving the state of the data as it was prior to those changes.
Once the COMMIT statement completes, the transaction's changes cannot be rolled back.
Commit;
Data definition
The Data Definition Language (DDL) manages table and index structure. The most basic
items of DDL are the CREATE, ALTER, RENAME, DROP and TRUNCATE statements:
Data control
The Data Control Language (DCL) authorizes users and groups of users to access and
manipulate data. Its two main statements are:
APPLET
An applet is any small application that performs one specific task; sometimes
running within the context of a larger program, perhaps as a plugin.[1][2] However, the term
typically also refers to programs written in the Java programming language which are
included in an HTML page
They have these methods because their superclass, java.applet.Applet, has these methods. (It
has others too, but right now I just want to talk about these four.)
Subclasses may override these methods to accomplish certain tasks at certain times. For
instance, the init() method is a good place to read parameters that were passed to the applet
via <PARAM> tags because it's called exactly once when the applet starts up. However, they
do not have to override them. Since they're declared in the superclass, the Web browser can
invoke them when it needs to without knowing in advance whether the method is
implemented in the superclass or the subclass. This is a good example of polymorphism.
The init() method is called exactly once in an applet's life, when the applet is first loaded. It's
normally used to read PARAM tags, start downloading any other images or media files you
need, and set up the user interface. Most applets have init() methods.
The start() method is called at least once in an applet's life, when the applet is started or
restarted. In some cases it may be called more than once. Many applets you write will not
have explicit start()methods and will merely inherit one from their superclass. A start()
method is often used to start any threads the applet will need while it runs.
The stop() method is called at least once in an applet's life, when the browser leaves the page
in which the applet is embedded. The applet's start() method will be called if at some later
point the browser returns to the page containing the applet. In some cases the stop() method
may be called multiple times in an applet's life. Many applets you write will not have explicit
stop()methods and will merely inherit one from their superclass. Your applet should use the
stop() method to pause any running threads. When your applet is stopped, it should not use
any CPU cycles.
The destroy() method is called exactly once in an applet's life, just before the browser
unloads the applet. This method is generally used to perform any final clean-up. For
example, an applet that stores state on the server might send some data back to the server
before it's terminated. many applets will not have explicit destroy() methods and just inherit
one from their superclass.
For example, in a video applet, the init() method might draw the controls and start loading
the video file. The start() method would wait until the file was loaded, and then start playing
it. The stop() method would pause the video, but not rewind it. If the start() method were
called again, the video would pick up where it left off; it would not start over from the
beginning. However, if destroy() were called and then init(), the video would start over from
the beginning.
In the JDK's appletviewer, selecting the Restart menu item calls stop() and then start().
Selecting the Reload menu item calls stop(), destroy(), and init(), in that order. (Normally the
byte codes will also be reloaded and the HTML file reread though Netscape has a problem
with this.)
The applet start() and stop() methods are not related to the similarly named methods in the
java.lang.Thread class.
Your own code may occasionally invoke start() and stop(). For example, it's customary to
stop playing an animation when the user clicks the mouse in the applet and restart it when
they click the mouse again.
Your own code can also invoke init() and destroy(), but this is normally a bad idea. Only the
environment should call init() and destroy().
Java uses the standard, two-dimensional, computer graphics coordinate system. The first
visible pixel in the upper left-hand corner of the applet canvas is (0, 0). Coordinates increase
to the right and down.
GRAPHIC OBJECTS:In Java all drawing takes place via a Graphics object. This is an
instance of the class java.awt.Graphics.
Initially the Graphics object you use will be the one passed as an argument to an applet's
paint() method. Later you'll see other Graphics objects too. Everything you learn today about
drawing in an applet transfers directly to drawing in other objects like Panels, Frames,
Buttons, Canvases and more.
Each Graphics object has its own coordinate system, and all the methods of Graphics
including those for drawing Strings, lines, rectangles, circles, polygons and more. Drawing in
Java starts with particular Graphics object. You get access to the Graphics object through the
paint(Graphics g) method of your applet. Each draw method call will look like
g.drawString("Hello World", 0, 50) where g is the particular Graphics object with which
you're drawing.
Load image:Image img = this.getImage(new URL("http://www.prenhall.com/logo.gif"));
Color is a class in the AWT. Individual colors like red or mauve are instances of this class,
java.awt.Color. Be sure to import it if you want to use other than the default colors. You
create new colors using the same RGB triples that you use to set background colors on web
pages. However you use decimal numbers instead of the hex values used by HTML's bgcolor
attribute. For example medium gray is Color(127, 127, 127). Pure white is Color(255, 255,
255). Pure red is (255, 0, 0) and so on. As with any variable you should give your colors
descriptive names. For instance
A few of the most common colors are available by name. These are
• Color.black
• Color.blue
• Color.cyan
• Color.darkGray
• Color.gray
• Color.green
• Color.lightGray
• Color.magenta
• Color.orange
• Color.pink
• Color.red
• Color.white
• Color.yellow
Choosing a font face is easy. First you create a new Font object. Then you call g.setFont(Font
f). To instantiate a Font object use this constructor:
name is the name of the font family, e.g. "Serif", "SansSerif", or "Mono".
size is the size of the font in points. In computer graphics a point is considered to be equal to
one pixel. 12 points is a normal size font. 14 points is probably better on most computer
displays. Smaller point sizes look good on paper printed with a high resolution printer, but
not in the lower resolutions of a computer monitor.
style is an mnemonic constant from java.awt.Font that tells whether the text will be bold,
italic or plain. The three constants are Font.PLAIN, Font.BOLD, and Font.ITALIC. The
program below prints each font in its own face and 14 point bold.
The following example is made simple enough to illustrate the essential use of Java applets
through its java.applet package. It also uses classes from the Java Abstract Window Toolkit
(AWT) for producing actual output (in this case, the "Hello, world!" message).
import java.applet.Applet;
import java.awt.*;
For compilation, this code is saved on a plain-ASCII file with the same name as the class and
.java extension, i.e. HelloWorld.java. The resulting HelloWorld.class applet should be
installed on the web server and is invoked within an HTML page by using an <APPLET> or
a <SCRIPT> tag. For example:
Displaying the HelloWorld_example.html page from a Web server, the result should look as
this:
To minimize download time, applets are usually delivered in a form of compressed zip
archive (having jar extension). If all needed classes (only one in our case) are placed in
compressed archive example.jar, the embedding code would look differently:
Advantages
• It is simple to make it work on Linux, Windows and Mac OS i.e. to make it cross
platform. Applets are supported by most web browsers
• The same applet can work on "all" installed versions of Java at the same time, rather
than just the latest plug-in version only. However, if an applet requires a later version of the
JRE the client will be forced to wait during the large download.
• Most web browsers cache applets, so will be quick to load when returning to a web
page. Applets also improve with use: after a first applet is run, the JVM is already running
and starts quickly (JVM will need to restart each time the browser starts fresh).
• It can move the work from the server to the client, making a web solution more
scalable with the number of users/clients
• If standalone program (like Google Earth) talks to the web server, that server
normally needs to support also previous versions as the user may not keep it always updated.
Differently, the browser updates the applet so there is no need to support the legacy versions.
Only due configuration mistakes the applet may get stuck in the cache and have issues when
new versions come out.
• The applet naturally supports the changing user state like figure positions on the
chessboard.
• Developers can develop and debug an applet direct simply by creating a main routine
(either in the applet's class or in a separate class) and call init() and start() on the applet, thus
allowing for development in their favorite J2SE development environment. All one has to do
after that is re-test the applet in the appletviewer program or a web browser to ensure it
conforms to security restrictions.
• An untrusted applet has no access to the local machine and can only access the server
it came from. This makes such applet much safer to run than standalone executable that it
could replace. However signed applet can have full access to the machine it is running on if
the user agrees.
Disadvantages
DATABASE CONNECTIVITY:
Java Database Connectivity (JDBC) provides Java developers with a standard API
that is used to access databases, regardless of the driver and database product. To use
JDBC, you'll need at least JDK 1.1, a database, and a JDBC driver. Installing the first two
should be straightforward, but finding a JDBC driver requires a little more effort. JDBC
presents a uniform interface to databases - change vendors and your applications only
need to change their driver.
There are plenty of drivers now for JDBC that support popular databases. If you can use a
JDBC driver that works specifically for your database, then that's great! If not, don't
worry - Sun provides a driver that is compatible with ODBC, so you should be able to
connect to any ODBC compliant database. The JDBC to ODBC bridge comes installed as
part of JDK1.1, so if this is your target platform, the driver will already be installed.
You'll need to create an ODBC datasource for your database, before your Java
applications can access it.
Connecting to a database
In order to connect to a database, you need to perform some initialization first. Your
JDBC driver has to be loaded by the Java Virtual Machine classloader, and your
application needs to check to see that the driver was successfully loaded. We'll be using
the ODBC bridge driver, but if your database vendor supplies a JDBC driver, feel free to
use it instead.
We try to load the JdbcOdbcDriver class, and then catch the ClassNotFoundException if
it is thrown. This is important, because the application might be run on a non-Sun virtual
machine that doesn't include the ODBC bridge, such as Microsoft's JVM. If this occurs,
the driver won't be installed, and our application should exit gracefully.
Once our driver is loaded, we can connect to the database. We'll connect via the driver
manager class, which selects the appropriate driver for the database we specify. In this
case, we'll only be using an ODBC database, but in more complex applications, we might
wish to use different drivers to connect to multiple databases. We identify our database
through a URL. No, we're not doing anything on the web in this example - a URL just
helps to identify our database.
A JDBC URL starts with "jdbc:" This indicates the protocol (JDBC). We also specify
our database in the URL. As an example, here's the URL for an ODBC datasource called
'demo'. Our final URL looks like this :
jdbc:odbc:demo
To connect to the database, we create a string representation of the database. We take the
name of the datasource from the command line, and attempt to connect as user "dba",
whose password is "sql".
Once you have an instance of a statement object, you can call its executeUpdate and
executeQuery methods. To illustrate the executeUpdate command, we'll create a table
that stores information about employees. We'll keep things simple and limit it to name
and employee ID.
Now that there's data in the table, we can execute queries. The response to a query will be
returned by the executeQuery method as a ResultSet object. ResultSet objects store the
last response to a query for a given statement object. Instances of ResultSet have methods
following the pattern of getXX where XX is the name of a data type. Such data types
include numbers (bytes, ints, shorts, longs, doubles, big-decimals), as well as strings,
booleans, timestamps and binary data.
// Execute query
ResultSet result = db_statement.executeQuery
("select * from employee");
SAMPLE: A Java applet that use JDBC applet driver to access a database
This sample shows how to write a Java Applet that uses the
JDBC Type 3 and 4 driver to access a DB2 database.
6. To run this sample, start your web browser (which must support
Java 1.3) and load Applt.html on your client machine.
You can view it locally with the following command:
appletviewer Applt.html
ECLIPSE WORKING:
1. Eclipse Overview
Eclipse an open source community whose projects building tools and frameworks for
creating general purpose application.
The most popular usage of Eclipse is as a Java development environment which will be
described in this article.
2 1.Installation
Download "Eclipse IDE for Java Developers" from the website Eclipse Downloads and
unpack it to a directory. This is sufficient for Eclipse to be used; no additional installation
procedure is required.
Use a directory path which does not contain spaces in its name.
Eclipse requires an installed Java Runtime. I recommended to use Java 6 (also known as
Java 1.6).
The system will prompt you for a workspace. The workspace is the place there you store
your Java projects (more on workspaces later). Select a suitable (empty) directory and
press Ok.
3. Eclipse UI Overview
Eclipse provides perspectives, views and editors. Views and editors are grouped into
perspectives. All projects are located in a workspace.
3.1. Workspace
The workspace is the physical location (file path) you are working in. You can choose the
workspace during startup of eclipse or via the menu (File-> Switch Workspace-> Others).
All your projects, sources files, images and other artifacts will be stored and saved in
your workspace.
To predefine the workspace you can use the startup parameter -data path_to_workspace,
e.g. c:\eclipse.exe -data "c:\temp" Please note that you have to put the path name into
brackets.
To see the current workspace directory in the title of Eclipse use -showLocation as
additional parameter.
3.2. Perspective
You can change the layout within a perspective (close / open views, editors, change the
size, change the position, etc.)
A common problem is that you closed a view and don't know how to re-open this view.
You can reset a perpective it to it original state via the menu "Window" -> "Reset
Perspective".
Eclipse allow you to switch to another perspective via the menu Window->Open
Perspective -> Other.
Editors are used to modify elements. Editors can have code completion, undo / redo, etc.
To apply the changes in an editor to the underlying resources, e.g. Java source file, you
usually have to save.
The following will describe how to create a minimal Java program using Eclipse. It will
be the classical "Hello World" program. Our program will write "Hello Eclipse!" to the
console.
Select from the menu File -> New-> Java project. Maintain "de.vogella.eclipse.ide.first"
as the project name. Select "Create separate source and output folders".
Press finish to create the project. A new project is created and displayed as a folder. Open
the folder "de.vogella.eclipse.ide.first"
Create now a package. A good convention is to use the same name for the top package as
the project. Create therefore the package "de.vogella.eclipse.ide.first".
Select the folder src, right mouse click on it and select New -> Package.
4.3. Create Java class
Create MyFirstClass, select the flag "public static void main (String[] args)"
Maintain the following code.
package de.vogella.eclipse.ide.first;
}
4.4. Run your project in Eclipse
Now run your code. Right click on your Java class and select Run-as-> Java application
4.5. Run your Java program outside Eclipse (create jar file)
To run your Java program outside of Eclipse you need to export it as a jar file. Select
your project, right click on it and select "Export".
Select JAR file, select next. Select your project and maintain the export destination and a
name for the jar file. I named it "myprogram.jar".
Press finish. This will create a jar file in your select output directory.
Open a command shell, e.g. under Microsoft Windows select Start -> Run and type in
cmd. This should open a consle.
Switch to your output directory, e.g. by typing cd path, e.g. if you jar is located in
"c:\temp" type "cd c:\temp".
To run this program you need to include the jar file into your classpath. See Classpath
and Java JAR Files for details.
import java.sql.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
/*<applet code="Word_Meaning.class" width=700 height=700>
</applet>*/
public class Word_Meaning extends Applet implements
ActionListener,TextListener,ItemListener
{
Font mf,mf1;
Choice tf1,tf3;
TextField tf2;
Choice tf4;
TextField tf5;
TextField tf6,tf7,tf8,tf9,tf10;
Button b1,b2,b3;
CheckboxMenuItem c1;
List l;
Label l0,l1,l2,l7,l8,l9,l3,l4,l5,l6,l10,l11;
Float time1,time2,ftime,ttime;
String
url,s1,s2,s3,s4,str1,str2,str3,str4,str5,str6,str7,nme,src,dest,selectString;
int i,seats,option;
Boolean flag,option1=false,option2=false;
public void init()
{
setBackground(Color.cyan);
l0=new Label("RAILWAY RESERVATION SYSTEM");
mf=new Font("TIMES ROMAN",Font.BOLD,30);
l0.setFont(mf);
l1=new Label("Enter the train name");
tf1=new Choice();
l3=new Label("Enter the Source station");
tf3=new Choice();
l4=new Label("Enter the destination station");
tf4=new Choice();
l5=new Label("Enter how many seats needed");
tf5=new TextField(30);
l2=new Label("Enter Date");
tf2=new TextField(30);
l10=new Label("Enter from time");
tf9=new TextField(30);
l11=new Label("Enter to time");
tf10=new TextField(30);
b1=new Button("Submit");
b2=new Button("Print Ticket");
b3=new Button("Check Availability");
c1=new CheckboxMenuItem("Hai");
l6=new Label("Enter Personal Details");
mf1=new Font("TIMES ROMAN",Font.BOLD,15);
l6.setFont(mf1);
l7=new Label("Enter name");
tf6=new TextField(30);
l8=new Label("Contact Information");
tf7=new TextField(30);
l9=new Label("Enter Train Details");
l9.setFont(mf1);
add(l0);
addNewLine(Color.cyan);
add(l6);
addNewLine(Color.cyan);
add(l7);
add(tf6);
addNewLine(Color.cyan);
add(l8);
add(tf7);
addNewLine(Color.cyan);
add(l9);
addNewLine(Color.cyan);
add(l1);
tf1.add("LF1"); tf1.add("FL1"); tf1.add("LH1");
tf1.add("HL1");tf1.add("LF2");tf1.add("FL2");tf1.add("LH2");tf1.add("HL2
");
add(tf1);
addNewLine(Color.cyan);
add(l3);
tf3.add("Hyderabad"); tf3.add("Lingampally");
tf3.add("Faluknama"); tf3.add("Necklace road"); tf3.add("Hitech city");
tf3.add("Begumpet"); tf3.add("Chandanagar"); tf3.add("Vidyanagar");
tf3.add("Kachiguda"); tf3.add("Malakpet"); tf3.add("Secunderabad");
add(tf3);
addNewLine(Color.cyan);
add(l4);
tf4.add("Hyderabad"); tf4.add("Lingampally");
tf4.add("Faluknama"); tf4.add("Necklace road"); tf4.add("Hitech city");
tf4.add("Begumpet"); tf4.add("Chandanagar"); tf4.add("Vidyanagar");
tf4.add("Kachiguda"); tf4.add("Malakpet"); tf4.add("Secunderabad");
add(tf4);
addNewLine(Color.cyan);
add(l5);
add(tf5);
addNewLine(Color.cyan);
add(l2);
add(tf2);
addNewLine(Color.cyan);
add(l10);
add(tf9);
addNewLine(Color.cyan);
add(l11);
add(tf10);
addNewLine(Color.cyan);
add(b3);
add(b1);
add(b2);
tf1.addItemListener(this);
tf3.addItemListener(this);
tf4.addItemListener(this);
tf5.addTextListener(this);
tf6.addTextListener(this);
tf7.addTextListener(this);
tf2.addTextListener(this);
tf9.addTextListener(this);
tf10.addTextListener(this);
b1.addActionListener(this);
b3.addActionListener(this);
b2.addActionListener(this);
}
while (rs.next())
{
String s5=rs.getString(1);
s3=rs.getString(5);
time1=Float.parseFloat(s3);
s4=rs.getString(6);
time2=Float.parseFloat(s4);
System.out.println("time::"+time1);
System.out.println("time::"+time2);
seats= rs.getInt(4);
if((seats>=i)&&(ftime<time1)&&(ttime>time1)&&(str1.equals(s5)))
{
flag=true;
break;
}
}
stmt.close();
con.close();
}
catch(SQLException ex)
{
System.err.println("SQLException1: " + ex.getMessage());
}
}
if(e.getSource()==b1)
{
option=1;
url="jdbc:odbc:student";
Statement stmt=null;
Connection con=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException le)
{
System.err.print("ClassNotFoundException: ");
System.err.println(le.getMessage());
}
try
{
con = DriverManager.getConnection(url,"scott", "tiger");
System.out.println("After connection");
}
catch(SQLException ex)
{
System.err.println("SQLException: " + ex.getMessage());
}
try
{
ResultSet rs=null;
stmt = con.createStatement();
if(i>0)
{
if (stmt.execute("select * from trainreservation1 where
noofseats>0"))
{
rs = stmt.getResultSet();
}
else
{
System.err.println("select failed");
}
}
String entry;
System.out.println("::"+stmt);
while (rs.next())
{
flag=false;
nme = rs.getString(1);
src = rs.getString(2);
dest = rs.getString(3);
seats= rs.getInt(4);
if(seats>=i)
{
if((ftime<time1)&&(ttime>time1))
{
System.out.println(":"+src);
System.out.println(":"+dest);
System.out.println(":"+nme);
if((nme.equals(str1))&&(src.equals(str3))&&(dest.equals(str4)))
{
int k;
k=seats-i;
stmt.executeUpdate("update trainreservation1 set noofseats='"+k+"'
where tname='"+str1+"'");
System.out.println("Successfully updated");
stmt.execute("insert into passenger1
values('"+str6+"','"+str1+"','"+str5+"','"+str2+"')");
flag=true;
break;
}
}
else
System.out.println("No trains in that time\n");
}
if(!flag)
System.out.println("not successful");
}
stmt.close();
con.close();
}
catch(SQLException ex)
{
System.err.println("SQLException1: " + ex.getMessage());
}
}
repaint();
}
}
TESTING
The second step includes Integration testing. It need not be the case, the
software whose modules when run individually and showing perfect results,
will also show perfect results when run as a whole. The individual modules
are clipped under this major module and tested again and verified the results.
This is due to poor interfacing, which may results in data being lost across
an interface. A module can have inadvertent, adverse effect on any other or
on the global data structures, causing serious problems.
The final step involves validation and testing which determines which
the software functions as the user expected. Here also some modifications
were. In the completion of the project it is satisfied fully by the end user.
RESULTS:
ScreenShots:
1. Home page :
2.Train Details:
FUTURE SCOPE
If anyone wants this project then he or she can make an additional
database of TRAINFARE. And database for update availability of seats
which is available after the cancellation of ticket on that specific train . etc.