Railway Reservation System



Comments



Description

RAILWAY RESERVATION SYSTEMTeam Members: K.L.Rajitha(09mcmt01) P.Manasa(09mcmt05) P.Suhasini(09mcmt10) D.Lavanya(09mcmt15) M.Sai Sudheer(09mcmt24) B.Manasa(09mcmt29) Work Done Coding Design Front End Coding Requirements Specification 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 We the students of M.tech(CS) from DCIS are grateful to the faculty of Software Engineering for involving us in building up a project on Railway Reservation System. We are thankful for the guidance and support extended by Ms.M.Nagamani in successful completion of the project. We are very lucky to have the grace of god and support from our parents in doing this project. ABSTRACT Designing a database for local train reservation system and trying to get an access to the database and reserve. This project deals with reserving tickets for the local trains which is heck these days .So inorder to make it convenient to travel we can book tickets priorily. This makes the travel smooth and convenient. This also helps in checking the details afterwards. INTRODUCTION Designing a database for local train reservation system and trying to get an access to the database and reserve. This project deals with reserving tickets for the local trains which is heck these days .So inorder to make it convenient to travel we can book tickets priorily. This makes the travel smooth and convenient. This also helps in checking the details afterwards. REQUIREMENTS SPECIFICATIONS SOFTWARE REQUIREMENTS: • Operating System – Windows XP • Eclipse 3.2 • Java 5.Pentium V duo core • Clock speed-700MHz Processor • Hard Disk-320GB • RAM-3GB .0 HARDWARE REQUIREMENTS: • Computer processor. Destination Station. PASSENGER TABLE TRAINRESERVATION TABLE: This table contains the details of trains Such as train name .PASSENGER TABLE: This table contains the details of passenger1 such as Traveler name. Arrival Time.of seats .DESIGN MODULES: DATABASE DESIGN: The tables used are 1. 2. No. TRAINRESRVATION TABLE 2. Source Station . date. . 1. source . Destination Time .destination. train name . The FROM clause can include optional JOIN subclauses to specify the rules for joining tables. which restricts the rows returned by the query.30. Data manipulation The Data Manipulation Language (DML) is the subset of SQL used to add. A query includes a list of columns to be included in the final result immediately following the SELECT keyword."LF1". SELECT retrieves data from one or more tables.11. SELECT * FROM trainreservation WHERE source=”lingampally”. . and data access control. The WHERE clause eliminates all rows from the result set for which the comparison predicate does not evaluate to True. update and delete data: • INSERT adds rows (formally tuples) to an existing table.x."lingampally". e.10. Its scope includes data query and update. and originally based upon Relational Algebra.20.SQL (Structured Query Language) SQL (Structured Query Language) is a database computer language designed for managing data in relational database management systems (RDBMS).. The asterisk (*) in the select list indicates that all columns of the trainreservation table should be included in the result set. schema creation and modification.: insert into trainreservation("LF1". with optional keywords and clauses that include: • • The FROM clause which indicates the table(s) from which data is to be retrieved."Hyd". The most common operation in SQL is the query. The WHERE clause includes a comparison predicate. or expressions. An asterisk ("*") can also be used to specify that the query should return all columns of the queried tables. which is performed with the declarative SELECT statement.30).g. The query retrieves all rows from the trainreservation in which the sourcr column contains a value as lingampally. The following is an example of a SELECT query that returns a list of trains available. insert into passenger("xyz". SELECT is the most complex statement in SQL.21-03-10). ALTER. Data control The Data Control Language (DCL) authorizes users and groups of users to access and manipulate data. adding a column to an existing table.source varchar(20). DML operations: COMMIT causes all data changes in a transaction to be made permanent.tname varchar(20). Its two main statements are: • GRANT authorizes one or more users to perform an operation or a set of operations on an object. for example) in the database. Transaction controls Transactions. • DELETE removes existing rows from a table. • ROLLBACK causes all data changes since the last COMMIT or ROLLBACK to be discarded. Data definition The Data Definition Language (DDL) manages table and index structure. RENAME.. if available.: DELETE FROM trainreservation WHERE psgname = 'sss'. .g.: UPDATE passenger SET noofseats=2 WHERE psgname = 'sss'.arrival number(12.Destination varchar(20). usually irretrievably. • • DROP deletes an object in the database. ALTER modifies the structure of an existing object in various ways—for example.Noofseats number(3). Once the COMMIT statement completes.2)).• UPDATE modifies a set of existing table rows. Eg: create table trairnreservation(tname varchar(20).Noofseats number(3).date varchar(20)). The most basic items of DDL are the CREATE.g.2).. DROP and TRUNCATE statements: • CREATE creates an object (a table. leaving the state of the data as it was prior to those changes. Eg:create table passenger(psgname varchar(20). e. the transaction's changes cannot be rolled back. Commit.departure number(12. e. 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. 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. In some cases the stop() method may be called multiple times in an applet's life. java. it should not use any CPU cycles. perhaps as a plugin. It's normally used to read PARAM tags. public void stop().applet. (It has others too. Your applet should use the stop() method to pause any running threads. when the applet is first loaded. Many applets you write will not have explicit start()methods and will merely inherit one from their superclass. The start() method is called at least once in an applet's life. and set up the user interface. public void destroy(). The init() method is called exactly once in an applet's life.Applet. A start() method is often used to start any threads the applet will need while it runs. the term typically also refers to programs written in the Java programming language which are included in an HTML page All applets have the following four methods: public void init(). For example. they do not have to override them. these are simply do-nothing methods. They have these methods because their superclass. when the browser leaves the page in which the applet is embedded. start downloading any other images or media files you need. public void start(). when the applet is started or restarted. . However. Many applets you write will not have explicit stop()methods and will merely inherit one from their superclass. sometimes running within the context of a larger program. The stop() method is called at least once in an applet's life. When your applet is stopped. In some cases it may be called more than once. For instance.) In the superclass. but right now I just want to talk about these four. This is a good example of polymorphism.[1][2] However. has these methods. which may be the default grant.• REVOKE eliminates a grant. public void init() {} Subclasses may override these methods to accomplish certain tasks at certain times. APPLET An applet is any small application that performs one specific task. Since they're declared in the superclass. The applet's start() method will be called if at some later point the browser returns to the page containing the applet. Most applets have init() methods. 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. . Java uses the standard. lines.awt. and all the methods of Graphics including those for drawing Strings.) The applet start() and stop() methods are not related to the similarly named methods in the java. For example. The stop() method would pause the video. If the start() method were called again. For example. GRAPHIC OBJECTS:In Java all drawing takes place via a Graphics object. Each draw method call will look like g. computer graphics coordinate system. This method is generally used to perform any final clean-up. Selecting the Reload menu item calls stop().Graphics. and then start playing it. circles. destroy(). selecting the Restart menu item calls stop() and then start(). but this is normally a bad idea. and init(). In the JDK's appletviewer. two-dimensional. Your own code may occasionally invoke start() and stop(). but not rewind it. the init() method might draw the controls and start loading the video file. 0). Buttons. if destroy() were called and then init(). the video would start over from the beginning. Frames. 50) where g is the particular Graphics object with which you're drawing. many applets will not have explicit destroy() methods and just inherit one from their superclass. Coordinates increase to the right and down.Thread class. just before the browser unloads the applet. The first visible pixel in the upper left-hand corner of the applet canvas is (0. rectangles. This is an instance of the class java. Only the environment should call init() and destroy(). Initially the Graphics object you use will be the one passed as an argument to an applet's paint() method. You get access to the Graphics object through the paint(Graphics g) method of your applet. (Normally the byte codes will also be reloaded and the HTML file reread though Netscape has a problem with this. Your own code can also invoke init() and destroy(). Drawing in Java starts with particular Graphics object. an applet that stores state on the server might send some data back to the server before it's terminated. For example. the video would pick up where it left off. Later you'll see other Graphics objects too. Each Graphics object has its own coordinate system. polygons and more.drawString("Hello World". However.lang.The destroy() method is called exactly once in an applet's life. Canvases and more. Everything you learn today about drawing in an applet transfers directly to drawing in other objects like Panels. it would not start over from the beginning. The start() method would wait until the file was loaded. in a video applet. 0. in that order. e. 50). 25).net. 255. 127.lightGray Color. 0) and so on. g. Color is a class in the AWT.applet.pink Color. Pure white is Color(255. These are • • • • • • • • • • • • • Color.setFont(Font f). . 50. "Serif". 127. "SansSerif".black Color.setColor(Color. int style.Applet. 255). 50.cyan Color.drawString("This String is pink!".Load image:Image img = this. 127).orange Color. or "Mono". 0. g. int size) name is the name of the font family.getColor().pink). g.getImage(new URL("http://www. 0).Color.drawString("This String is green!". As with any variable you should give your colors descriptive names. java. For instance Color medGray = new Color(127. g. 187).red Color. g.setColor(Color. To instantiate a Font object use this constructor: public Font(String name. The getImage() method is provided by java. A few of the most common colors are available by name.awt. Be sure to import it if you want to use other than the default colors.prenhall. 55. The URL class is provided by java. For example medium gray is Color(127.com/logo.URL. Be sure to import it. You create new colors using the same RGB triples that you use to set background colors on web pages. Pure red is (255. Color cream = new Color(255.green).blue Color.yellow Color oldColor = g. Color lightGreen = new Color(0.gif")).g. 127). Choosing a font face is easy.gray Color. 231.darkGray Color. First you create a new Font object. Then you call g. Individual colors like red or mauve are instances of this class.green Color. However you use decimal numbers instead of the hex values used by HTML's bgcolor attribute.setColor(oldColor).magenta Color.white Color. org/TR/html4/loose.applet package. } } For compilation.applet package The following example is made simple enough to illustrate the essential use of Java applets through its java.Font that tells whether the text will be bold. 14 points is probably better on most computer displays.html</TITLE> </HEAD> .awt. but not in the lower resolutions of a computer monitor. 12 points is a normal size font. Font.. For example: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.e. In computer graphics a point is considered to be equal to one pixel. the "Hello.class applet should be installed on the web server and is invoked within an HTML page by using an <APPLET> or a <SCRIPT> tag. style is an mnemonic constant from java. this code is saved on a plain-ASCII file with the same name as the class and .10). // Applet code for the "Hello.awt.java. i.*.dtd"> <HTML> <HEAD> <TITLE>HelloWorld_example.e. It also uses classes from the Java Abstract Window Toolkit (AWT) for producing actual output (in this case.BOLD. public class HelloWorld extends Applet { // This method is mandatory.drawString("Hello. and Font. The program below prints each font in its own face and 14 point bold.PLAIN. world!" message). A basic example using the java. HelloWorld.size is the size of the font in points.java extension.ITALIC. 20.01 Transitional//EN" "http://www.w3. import java. world!" example. public void init() { } // This method is mandatory. but can be empty (i. // This should be saved in a file named as "HelloWorld. The three constants are Font.applet. world!". public void paint(Graphics g) { g. have no actual code). but can be empty. Smaller point sizes look good on paper printed with a high resolution printer. import java.java". y=10).Applet. italic or plain. public void stop() { } // Print a message on the screen (x=20. The resulting HelloWorld. Only due configuration mistakes the applet may get stuck in the cache and have issues when new versions come out. world! To minimize download time. Differently. Applets are supported by most web browsers • The same applet can work on "all" installed versions of Java at the same time. Applets also improve with use: after a first applet is run.class runs.class runs. thus allowing for development in their favorite J2SE development environment. All one has to do • . the result should look as this: A Java applet example Here it is: Hello.html page from a Web server. If all needed classes (only one in our case) are placed in compressed archive example.class" WIDTH="200" HEIGHT="40"> This is where HelloWorld. making a web solution more scalable with the number of users/clients • If standalone program (like Google Earth) talks to the web server. • Most web browsers cache applets. the browser updates the applet so there is no need to support the legacy versions.<BODY> <H1>A Java applet example</H1> <P>Here it is: <APPLET code="HelloWorld. rather than just the latest plug-in version only. applets are usually delivered in a form of compressed zip archive (having jar extension). to make it cross platform.</APPLET></P> </BODY> </HTML> Displaying the HelloWorld_example. Windows and Mac OS i. if an applet requires a later version of the JRE the client will be forced to wait during the large download.</APPLET></P> Advantages A Java applet can have any or all of the following advantages: It is simple to make it work on Linux. the JVM is already running and starts quickly (JVM will need to restart each time the browser starts fresh). • The applet naturally supports the changing user state like figure positions on the chessboard.jar. • It can move the work from the server to the client.e. • 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.jar"> This is where HelloWorld. However. so will be quick to load when returning to a web page. that server normally needs to support also previous versions as the user may not keep it always updated. the embedding code would look differently: <P>Here it is: <APPLET code="HelloWorld" WIDTH="200" HEIGHT="40" ARCHIVE="example. If you can use a JDBC driver that works specifically for your database.change vendors and your applications only need to change their driver. Disadvantages A Java applet may have any of the following disadvantages: It requires the Java plug-in. JDBC presents a uniform interface to databases . and a JDBC driver. • • DATABASE CONNECTIVITY: Java Database Connectivity (JDBC) provides Java developers with a standard API that is used to access databases. This makes such applet much safer to run than standalone executable that it could replace. Some organizations only allow software installed by the administrators. some users can only view applets that are important enough to contact the administrator asking to install the Java plug-in. before your Java applications can access it. However signed applet can have full access to the machine it is running on if the user agrees. This makes applet with specific requirements impossible to run unless Java is manually updated. • Some applets require a specific JRE. Java automatic updater that is part of Java installation also may be complex to configure if it must work through proxy. There are plenty of drivers now for JDBC that support popular databases. the object tag needs workarounds to write a cross-browser HTML. a database.1. don't worry . This is discouraged [22].Sun provides a driver that is compatible with ODBC. • An untrusted applet has no access to the local machine and can only access the server it came from. security restrictions may make difficult or even impossible for untrusted applet to achieve the desired goals. To use JDBC. then that's great! If not. . As a result. Installing the first two should be straightforward. • Java automatic installation or update may fail if proxy is used to access the web. but finding a JDBC driver requires a little more effort. • Unlike the older applet tag. you'll need at least JDK 1. • As with any client side scripting. The JDBC to ODBC bridge comes installed as part of JDK1. You'll need to create an ODBC datasource for your database. • If applet requires newer or specific JRE than available on the system. so if this is your target platform. so you should be able to connect to any ODBC compliant database. the driver will already be installed.after that is re-test the applet in the appletviewer program or a web browser to ensure it conforms to security restrictions.1. the user running it first time will need to wait for the large JRE download to complete. regardless of the driver and database product. such as Microsoft's JVM. whose password is "sql".jdbc. // Create a URL that identifies database String url = "jdbc:odbc:" + args[0].exit(0). Our final URL looks like this : jdbc:odbc:demo To connect to the database. If this occurs. here's the URL for an ODBC datasource called 'demo'. and attempt to connect as user "dba". you need to perform some initialization first.odbc. but if your database vendor supplies a JDBC driver. and your application needs to check to see that the driver was successfully loaded.newInstance(). We'll be using the ODBC bridge driver. we might wish to use different drivers to connect to multiple databases. As an example.a URL just helps to identify our database. A JDBC URL starts with "jdbc:" This indicates the protocol (JDBC). we can connect to the database.err. feel free to use it instead. This is important. we'll only be using an ODBC database. We identify our database through a URL. we're not doing anything on the web in this example . because the application might be run on a non-Sun virtual machine that doesn't include the ODBC bridge.Connecting to a database In order to connect to a database. } We try to load the JdbcOdbcDriver class. and our application should exit gracefully. We take the name of the datasource from the command line.println ("Unable to load database driver"). System. We also specify our database in the URL. Once our driver is loaded. .err. System.println ("Details : " + cnfe). which selects the appropriate driver for the database we specify. and then catch the ClassNotFoundException if it is thrown. We'll connect via the driver manager class. } catch (ClassNotFoundException cnfe) // driver not found { System. // Attempt to load database driver try { // Load Sun's jdbc-odbc driver Class.forName("sun.JdbcOdbcDriver"). the driver won't be installed. Your JDBC driver has to be loaded by the Java Virtual Machine classloader. In this case. but in more complex applications. we create a string representation of the database. No. Statement objects support two main types of statements .executeUpdate ("create table employee { int id.executeUpdate ("insert into employee values (1. longs. we'll create a table that stores information about employees. we use a statement object to execute queries.// Now attempt to create a database connection Connection db_connection = DriverManager.next() ) { // Use the getInt method to obtain emp. // Insert an employee. id . ints. The response to a query will be returned by the executeQuery method as a ResultSet object. as well as strings. so the table contains data db_statement. // Create a simple table. connecting to a database doesn't take much code. you can call its executeUpdate and executeQuery methods.executeQuery ("select * from employee"). if needed. "sql")."). Such data types include numbers (bytes. "dba". A statement object is responsible for sending the SQL statement. shorts.createStatement(). Once you have an instance of a statement object. we can execute queries. timestamps and binary data. 'John Doe'). from the query. Executing database queries In JDBC. We'll keep things simple and limit it to name and employee ID. which stores an employee ID and name db_statement. // Commit changes db_connection.an update statement that is normally used for operations which don't generate a response. and a query statement that returns data. char(50) name }."). ResultSet objects store the last response to a query for a given statement object. As you can see. big-decimals). // Execute query ResultSet result = db_statement. To illustrate the executeUpdate command. and returning a set of results. booleans. doubles.commit(). // Create a statement to send SQL Statement db_statement = db_connection. Instances of ResultSet have methods following the pattern of getXX where XX is the name of a data type. Now that there's data in the table.getConnection (url. // While more rows exist. print them while (result. Ensure that your working directory is accessible by your web browser.html into a directory that is accessible. start your web browser (which must support Java 1. you can compile the program with the following command if you have a compatible make/nmake program on your system: make/nmake Applt 4. copy sqllib\java\db2jcc. Create and populate the "sample" database with the following command: db2sampl 2. Run this sample using the following steps: 1.java Alternatively. If it is not. copy Applt. You can view it locally with the following command: appletviewer Applt. port.println ("ID : " + result.getString("Name")). Customize Applt.3) and load Applt. To use the JDBC Type 4 driver. // Use the getString method to obtain emp.html on your client machine. } 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.println ("Name : " + result.println ().class and Applt.out.out. 3. and password.class and Applt. Refer to Applt.out. System. into the same directory as Applt. To run this sample.html . 6.System. name System. user ID. 5.html with your server. this sample uses JDBC Type 4 driver to connect to the "sample" database (Recommended).html.jar on UNIX. Compile the program with the following command: javac Applt.getInt("ID")).jar on Windows or sqllib/java/db2jcc. By default.html for details. 2. Eclipse Overview Eclipse an open source community whose projects building tools and frameworks for creating general purpose application. Eclipse will start and show the Welcome page. I recommended to use Java 6 (also known as Java 1. . Start Eclipse To start Eclipse double-click on the file eclipse. The system will prompt you for a workspace. Use a directory path which does not contain spaces in its name.6).Installation Download "Eclipse IDE for Java Developers" from the website Eclipse Downloads and unpack it to a directory.exe in your installation directory. 2 1. Eclipse requires an installed Java Runtime. The workspace is the place there you store your Java projects (more on workspaces later). This is sufficient for Eclipse to be used. Select a suitable (empty) directory and press Ok.ECLIPSE WORKING: 1. no additional installation procedure is required. The most popular usage of Eclipse is as a Java development environment which will be described in this article.2. 3. 3. Workspace The workspace is the physical location (file path) you are working in. images and other artifacts will be stored and saved in your workspace.1. Views and editors are grouped into perspectives.g. sources files. . You can choose the workspace during startup of eclipse or via the menu (File-> Switch Workspace-> Others).Close the welcome page by press in little x besides the Welcome.exe -data "c:\temp" Please note that you have to put the path name into brackets. All projects are located in a workspace. views and editors. All your projects. Eclipse UI Overview Eclipse provides perspectives. e. To predefine the workspace you can use the startup parameter -data path_to_workspace. c:\eclipse. . change the size. Changes in a view are directly applied.To see the current workspace directory in the title of Eclipse use -showLocation as additional parameter. e. undo / redo. Perspective A perspective is a visual container for a set of views and editors. Editors are used to modify elements.) A common problem is that you closed a view and don't know how to re-open this view. Create project Select from the menu File -> New-> Java project. 3. Views and Editors A view is typically used to navigate a hierarchy of information or to open an editor.vogella.ide. Java source file. For Java development you usually use the "Java Perspective". editors.3. To apply the changes in an editor to the underlying resources. 4.g.eclipse. 4. Select "Create separate source and output folders". change the position. You can reset a perpective it to it original state via the menu "Window" -> "Reset Perspective". 3.first" as the project name. you usually have to save. etc. Eclipse allow you to switch to another perspective via the menu Window->Open Perspective -> Other. Our program will write "Hello Eclipse!" to the console. Maintain "de.2.1. Editors can have code completion. Create your first Java program The following will describe how to create a minimal Java program using Eclipse. etc. You can change the layout within a perspective (close / open views. It will be the classical "Hello World" program. Press finish to create the project.vogella. right mouse click on it and select New -> Package.2. A good convention is to use the same name for the top package as the project.vogella.ide.ide. Select the folder src.eclipse. Create package Create now a package. .first" 4.eclipse. A new project is created and displayed as a folder.first". Create therefore the package "de. Open the folder "de. select the flag "public static void main (String[] args)" . Create Java class Right click on your package and select New -> Class Create MyFirstClass.4.3. vogella.eclipse.out. package de.ide.println("Hello Eclipse!"). public class MyFirstClass { public static void main(String[] args) { System. } } .first.Maintain the following code. Right click on your Java class and select Run-as-> Java application Finished! You should see the output in the console. . Run your project in Eclipse Now run your code.5. right click on it and select "Export". Select your project.4.4. 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. 4. Select JAR file. Select your project and maintain the export destination and a name for the jar file.jar". I named it "myprogram. . select next. This will create a jar file in your select output directory. e.MyFirstClass . Run your program outside Eclipse Open a command shell.g. e. by typing cd path.vogella. 4. This should open a consle.6.Press finish. if you jar is located in "c:\temp" type "cd c:\temp".ide. under Microsoft Windows select Start -> Run and type in cmd. Switch to your output directory.first.g. To run this program you need to include the jar file into your classpath. java -classpath myprogram. See Classpath and Java JAR Files for details.jar de.g. e.eclipse. Fig1:class diagram for railway reservation . Ivar Jacobson. UML is accepted by the Object Management Group (OMG) as the standard for modeling object oriented programs. These renowned computer scientists fused their respective technologies into a single. CLASS DIAGRAM: Class diagram is a collection set of objects. and the Rational Software Corporation. standardized model. Today. This object-oriented system of notation has evolved from the work of Grady Booch. James Rumbaugh.UML DIAGRAMS: UML stands for Unified Modeling Language. USECASE DIAGRAM: Use case diagrams model the functionality of system using actors and use cases . .SEQUENCE DIAGRAM: Sequence diagrams describe interactions among classes in terms of an exchange of messages over time. DEPLOYMENT DIAGRAM: Deployment diagrams depict the physical resources in a system. runtime (binary) code. Component diagrams describe the organization of physical software components. including source code. and executables. including nodes. . and connections. components. including source code. . and executables. run-time (binary) code.COMPONENT DIAGRAM: Component diagrams describe the organization of physical software components. str2.l11.l1. import java.cyan).*. Button b1.str7.awt.event. TextField tf2. import java.class" width=700 height=700> </applet>*/ public class Word_Meaning extends Applet implements ActionListener.tf3. l1=new Label("Enter the train name").Font.time2. TextField tf5. l0. import java.src.s1.s4.l3.ItemListener { Font mf.nme.l4.option.io.tf10.option1=false.l7.selectString.BOLD. import java.*. public void init() { setBackground(Color. Float time1.str6. Boolean flag.30). List l.l9.ftime.l5. mf=new Font("TIMES ROMAN".option2=false. .tf7. Label l0.str1. int i.l2.ttime. CheckboxMenuItem c1.s3.b3.dest.str4. /*<applet code="Word_Meaning.IMPLEMENTATION: CODING: Javacode: import java.tf9.l8.tf8. Choice tf4.l6.sql.TextListener.*. Choice tf1.applet.seats.b2. l0=new Label("RAILWAY RESERVATION SYSTEM").*.str5.*. TextField tf6.str3.awt.s2.l10. String url.setFont(mf).mf1. cyan). tf9=new TextField(30).cyan). b2=new Button("Print Ticket"). tf6=new TextField(30). b3=new Button("Check Availability"). b1=new Button("Submit"). l10=new Label("Enter from time"). add(l9). addNewLine(Color.cyan). tf5=new TextField(30). add(l7). tf3=new Choice(). add(l1). tf10=new TextField(30). l2=new Label("Enter Date"). l6. tf7=new TextField(30). add(tf6).setFont(mf1). tf2=new TextField(30). l5=new Label("Enter how many seats needed"). addNewLine(Color. addNewLine(Color. add(tf7).cyan). l9. l6=new Label("Enter Personal Details"). tf4=new Choice(). add(l6). l4=new Label("Enter the destination station"). add(l8).cyan).BOLD.tf1=new Choice().15). . addNewLine(Color. l3=new Label("Enter the Source station"). c1=new CheckboxMenuItem("Hai"). add(l0).setFont(mf1). l11=new Label("Enter to time"). l9=new Label("Enter Train Details"). mf1=new Font("TIMES ROMAN". addNewLine(Color. l7=new Label("Enter name"). l8=new Label("Contact Information").Font. add("HL1").addTextListener(this). add(l3).add("Necklace road"). add(b1).add("Faluknama").add("Begumpet"). tf4.add("Lingampally"). tf7. addNewLine(Color.add("Hyderabad").add("Necklace road"). tf4.add("Hyderabad").add("LF1"). add(l4). tf4.tf1.cyan).addTextListener(this).add("HL2 ").add("Kachiguda"). tf6. add(l5). addNewLine(Color.add("LF2"). tf1. tf1.add("LH1").add("Secunderabad"). tf3.add("FL2"). tf3.add("FL1").tf1.cyan). tf3. add(tf10). .add("Hitech city").addItemListener(this).add("Faluknama"). tf3. tf1.addItemListener(this). tf4.tf1. tf4. addNewLine(Color.add("Hitech city").cyan). tf3.add("Lingampally"). addNewLine(Color. add(l10). tf4. tf3. add(b2).cyan). tf4.tf1. tf1. tf4. tf5.add("Chandanagar"). tf4. add(b3).add("Vidyanagar"). addNewLine(Color. add(l11). add(l2).add("Kachiguda").add("Secunderabad"). tf4.addItemListener(this). tf3. tf3. add(tf4).add("Malakpet").cyan). tf3. add(tf2). tf3.add("Chandanagar").tf1. tf4. tf3. addNewLine(Color.add("Begumpet").add("Vidyanagar"). add(tf9). addNewLine(Color.cyan).addTextListener(this).add("LH2").cyan). tf3. tf4. add(tf3). add(tf5).add("Malakpet"). add(tf1). } public void itemStateChanged(ItemEvent ie) { if(ie. System. tf9.addActionListener(this).println("tname::"+str1).addActionListener(this).null).white. System. } if(ie. } repaint().addActionListener(this).setSize(10000.getSource()==tf3) { str3=tf3.println("destination::"+str4).1).addTextListener(this). b1.setBackground(c).getSelectedItem(). System. b3.addTextListener(this). line. } if(ie.getSource()==tf4) { str4=tf4.tf2.out.println("source::"+str3).getSource()==tf1) { str1=tf1. } public void paint(Graphics g) { showStatus("TRAIN").drawImage(bg. //g.Color.0.out. add(line).out.0. if(option==1) . //super.getSelectedItem().paint(g).getSelectedItem(). } private void addNewLine(Color c) { Canvas line=new Canvas(). tf10. b2. line.addTextListener(this). 500.520). else g.drawString("CONTACT INFO::"+str7.560).500).540).drawString("CHECK AVAILABILITY!!!!!!".{ if(option1==true&&flag==true) g.500.500. g.500.600). g.500. } else g.getSource()==tf5) .drawString("NUMBER OF SEATS::"+str5. g. g.620). g. g.drawString("NAME::"+str6.drawString("DATE::"+str2.500. g.500). option1=true.500. } } } public void textValueChanged(TextEvent e) { if(e.drawString("SOURCE::"+str3. } if(option==2) { if(option2==true&&flag==true) { g.drawString("DESTINATION::"+str4. } else { flag=false.520). } if(option==3) { if(flag==true) { option2=true.drawString("SEATS ARE AVAILABLE". g.500.drawString("CHECK AVAILABILITY!!!!!!".500.500.drawString("SORRY!!! SEATS ARE NOT AVAILABLE".drawString("SUCCESSFULLY BOOKED::"+i.500).500.drawString("TRAIN NAME::"+str1.520).520).500.580). } } public void actionPerformed(ActionEvent e) { if(e.out.getSource()==tf2) { str2=tf2.getText(). . System. ftime=Float. i=Integer.getText().getText(). Statement stmt=null.getSource()==tf7) { str7=tf7. } if(e. } if(e.parseFloat(s2). } if(e. System.parseInt(str5).getSource()==tf6) { str6=tf6.getText(). } if(e.getSource()==tf9) { s1=tf9.getSource()==b3) { option=3.println("to time by user"+ttime).getText(). } if(e.getSource()==b2) { option=2.{ str5=tf5.println("from time by user"+ftime).getSource()==tf10) { s2=tf10. } if(e. url="jdbc:odbc:student".out.getText().parseFloat(s1). ttime=Float. println("select failed").Connection con=null.err. flag=false.odbc. } catch(SQLException ex) { System. "tiger"). } } System.err.println(le.JdbcOdbcDriver").forName("sun.jdbc.createStatement()."scott".print("ClassNotFoundException: ").getMessage()).getConnection(url.out. System.lang.ClassNotFoundException le) { System.getMessage()).getResultSet().execute("select * from trainreservation1 where noofseats>0")) { rs = stmt. System. stmt = con. } try { ResultSet rs=null. } catch(java. if(i>0) { if (stmt.err.println("SQLException: " + ex. } else { System. while (rs.next()) { .err. try { Class.println("After connection").println("::"+stmt).out. } try { con = DriverManager. if((seats>=i)&&(ftime<time1)&&(ttime>time1)&&(str1. System.getString(1).parseFloat(s4). time1=Float.jdbc. time2=Float.err.getMessage()).println("SQLException1: " + ex.lang.forName("sun.parseFloat(s3). } } if(e. s3=rs.String s5=rs.err.ClassNotFoundException le) { System. break.getString(5).println(le.out.getString(6).print("ClassNotFoundException: ").equals(s5))) { flag=true.close().close().getSource()==b1) { option=1.println("time::"+time1). try { Class. } catch(SQLException ex) { System. url="jdbc:odbc:student".JdbcOdbcDriver"). Statement stmt=null.println("time::"+time2).getMessage()). Connection con=null.odbc. seats= rs. System. } try { .err. } } stmt. s4=rs. } catch(java.out. System. con.getInt(4). "tiger").execute("select * from trainreservation1 where noofseats>0")) { rs = stmt.getString(1).println("::"+stmt).getString(2). dest = rs.out.equals(str3))&&(dest. } catch(SQLException ex) { System.createStatement().getInt(4).err.equals(str1))&&(src. System. src = rs."scott". System.next()) { flag=false.out.getMessage()).out.println("After connection"). System.getConnection(url. } try { ResultSet rs=null.println(":"+dest). if(i>0) { if (stmt.equals(str4))) . seats= rs.out. System. if(seats>=i) { if((ftime<time1)&&(ttime>time1)) { System. if((nme.println(":"+src).println("SQLException: " + ex.getString(3).err. nme = rs. while (rs.getResultSet().out. } else { System. } } String entry.con = DriverManager.println("select failed").println(":"+nme). stmt = con. break.'"+str2+"')").println("No trains in that time\n").'"+str1+"'.out.out.close(). } } .println("SQLException1: " + ex. } } repaint(). } stmt.{ int k. stmt. } } else System.executeUpdate("update trainreservation1 set noofseats='"+k+"' where tname='"+str1+"'").close().getMessage()). stmt. con. } catch(SQLException ex) { System.out.execute("insert into passenger1 values('"+str6+"'. flag=true. k=seats-i.err.println("Successfully updated"). } if(!flag) System. System.'"+str5+"'.println("not successful"). The second step includes Integration testing. This is due to poor interfacing. will also show perfect results when run as a whole. adverse effect on any other or on the global data structures. validity and also determine any missing operations and to verify whether the objectives have been met. where in each module is tested to provide its correctness. Software testing is carried out in three steps: The first includes unit testing. So errors are rectified easily in particular module and program clarity is increased. causing serious problems. The final step involves validation and testing which determines which the software functions as the user expected. which may results in data being lost across an interface. In the completion of the project it is satisfied fully by the end user. Here also some modifications were. In this project entire system is divided into several modules and is developed individually. Errors are noted down and corrected immediately. . Unit testing is the important and major part of the project. The individual modules are clipped under this major module and tested again and verified the results. the software whose modules when run individually and showing perfect results. So unit testing is conducted to individual modules. It is the process of finding errors and missing operations and also a complete verification to determine whether the objectives are met and the user requirements are satisfied. It need not be the case. A module can have inadvertent.TESTING The testing phase is an important part of software development. Home page : .RESULTS: ScreenShots: 1. Train Details: 3.Check the availability of seats: .2. After booking the ticket: .4. 5.PRINTING TICKET: . 6.Seats not available: . Testcase_1 ScreenShot: .7. . Screen shot for seats are not available: .8:Testcase_2 ScreenShot: 9. . And database for update availability of seats which is available after the cancellation of ticket on that specific train . etc. He or she can also add some command buttons in the existing software and extend working of the software. FUTURE SCOPE If anyone wants this project then he or she can make an additional database of TRAINFARE. .CONCLUSION In the last we conclude that MMTs Railways is having a strong IT Infrastructure and a well equipped railway reservation system but there is some shortcoming in the system on which we have tried to work on it and successfully completed our project.
Copyright © 2024 DOKUMEN.SITE Inc.