Ayushman Samantaray Final Ip Project SH
Ayushman Samantaray Final Ip Project SH
SCHOOL
HALDIA
A
PROJECT DOCUMENTATION
ON
<Page 1 of 57>
CONTENTS
1. Certificate
2. Acknowledgment
7. Classes, GUI Controls & Objects used (Description of user defined classes and their
purpose)
8. Functions (Description of user defined functions and their purpose)
9. Data Flow
10. Source Code (listing of all the programs prepared as part of project. )
11. Testing & Output (Dumps of all the Output Screens)
12. Conclusion
13. Maintenance
16. Bibliography
<Page 2 of 57>
BHARATIYA VIDYA
BHAVAN’S SCHOOL
HALDIA
CERTIFICATE
This is to
Computer Lab of BHARATIYA VIDYA BHAVAN SCHOOL. The project has been
<Page 3 of 57>
ACKNOWLEDGEMENT
I express my deepest gratitude towards Mr. Simit Roy, PGT, Comp. Sc., Bharatiya
Vidya Bhavan School,Haldia for giving me his valuable suggestions and help in the
Finally, I would like to thank all the other members for helping me for
completion of this project. And above all, I am very much thankful to my friends
Finally, I would like to thank all the other School Automation for helping me
for completion of this project. And above all, I am very much thankful to my
friends who had helped me for the completion of this project report.
<Page 4 of 57>
Overview of Techniques used through the Language of
JAVA, HTML & RDBMS
This software is developed by using various software methodologies, involving the Object
Oriented Programming approaches to access Database using ODBC, in java it has been
implemented using JDBC connection to store and retrieve data through java API to automate the
INVENTORY CONTROL SYSTEM of a Sports.
DATA TYPES:
1. Primitive Data Ty pes / Built-in Data Ty pes:
2. Reference Data Ty pes
PRIMITIVE DATA TYPES / BUILT-IN DATA TYPES: The eight primitive data types
supported by the Java programming language are: byte, short, int, long, float, double, boolean,
and char.
<Page 5 of 57>
There are built in function to convert string to other built in data types:
byte Byte Byte.parseByte(String) –Convert String to byte short
Short.parseShort(String) –Convert String to short int
Integer.parseInt(String) –Convert String to int
long Long.parseLong(String) –Convert String to long float
Float.parsefloat(String) –Convert String to float
double Double.parseInt(String) –Convert String to Double boolean
Boolean.valueOf(String).boolean.Value() -
CONTROL STRUCTURES
Java Decision Making
There are two types of decision making statements in Java. They are: if
statements
switch statements
The if Statement:
An if statement consists of a Boolean expression followed by one or more statements.
Syntax:
if(Boolean_expression)
{
/Statements will execute if the Boolean expression is true
}
for(int x : numbers ){
System.out.print( x );
System.out.print(",");
}
System.out.print("\n");
String [] names ={"James", "Larry", "Tom", "Lacy"}; for(
String name : names ) {
System.out.print( name );
System.out.print(",");
}
}
}
This would produce following result:
10,20,30,40,50,
James,Larry,Tom,Lacy,
CONCEPT OF A METHOD:
Method: A Java method is a collection of statements that are grouped together to perform an
operation.
Creating a Method:
In general, a method has the following sy ntax:
modifier returnValueTy pe methodName(list of parameters) {
/ Method body;
}
A method definition consists of a method header and a method body. Here are all the parts of a
method:
Modifiers: The modifier, which is optional, tells the compiler how to call the method.
This defines the access type of the method.
Return Ty pe: A method may return a value. The returnValueTy pe is the data type of the
value the method returns. Some methods perform the desired operations without returning
a value. In this case, the returnValueTy pe is the keyword void.
Method Name: This is the actual name of the method. The method name and the
parameter list together constitute the method signature.
Parameters: A parameter is like a placeholder. When a method is invoked, you pass a
value to the parameter. This value is referred to as actual parameter or argument. The
parameter list refers to the type, order, and number of the parameters of a method.
Parameters are optional; that is, a method may contain no parameters.
Method Body: The method body contains a collection of statements that define what the
method does.
return result;
}
Calling a Method:
In creating a method, you give a definition of what the method is to do. To use a method, you
have to call or invoke it. There are two ways to call a method; the choice is based on whether the
method returns a value or not.
If the method returns a value, a call to the method is usually treated as a value. For example:
int larger = max(30, 40);
If the method returns void, a call to the method must be a statement. For example, the method println
returns void. The following call is a statement:
System.out.println("Welcome to Java!");
The void Keyword: This section shows how to declare and invoke a void method. Following
example gives a program that declares a method named printGrade and invokes it to print the
grade for a given score.
Passing Parameters by Values: When calling a method, you need to provide arguments, which
must be given in the same order as their respective parameters in the method specification. This
is known as parameter order association.
For example, the following method prints a message n times:
public static void nPrintln(String message, int n) {
Object - Objects have states and behaviors. Example: A dog has states-color, name, breed as well
as behaviors -wagging, barking, eating. An object is an instance of a class.
Class - A class can be defined as a template/ blue print that describe the behaviors/ states that
object of its type support.
Objects in Java: Like real world objects, Java software objects are with properties (data
member) and behavior (methods). In software development methods operate on the internal state
of an object and the object-to-object communication is done via methods.
Classes in Java: A class is a blue print from which individual objects are created. A sample
of a class is given below:
public class Dog
{
String breed;
int age; String
color;
void barking(){
}
void hungry(){
}
void sleeping(){
}
}
Instance variables .Instance variables are variables within a class but outside any
method. These variables are instantiated when the class is loaded. Instance variables can
be accessed from inside any method, constructor or blocks of that particular class.
Class variables .Class variables are variables declared with in a class, outside any
method, with the static keyword.
Constructors:
A class contains method / function having same name as the class name and have no return type.
A Constructor is invoked to create objects from the class blueprint and also initialize the data
members with some legal values.
- Implicit Constructor / Default Constructor: A constructor without any argument or
default argument.
- Explicit Constructor / User defined Constructor: A constructor defined by the user.
Example constructor:
import java.io.*; public
class Employee
{
int empno
String name;
String designation;
double salary;
public Employee() // This is the default constructor
{
empno = 0;
age=0; salary=0.0d;
}
}
Constructor Overloading: A class having more than one member functions and differentiated
according to their no. of arguments and type of arguments is called constructor overloading.
Example of constructor overloading:
public class Employee
{
[ Data Member[s] ]
public Employee() / This is the default constructor
{
/ Initialization of the Object
}
public Employee (String empName)
{
name = empName;
}
}
Note: Java also supports Singleton Classes where you would be able to create only one instance of a
class.
Creating an Object: As mentioned previously a class provides the blueprints for objects. So
basically an object is created from a class. In java the new key word is used
Accessing Instance Variables and Methods: Instance variables and methods are accessed via
created objects. To access an instance variable the fully qualified path should be as follows:
/* First create an object */ ObjectReference =
new Constructor();
Example:
This example explains how to access instance variables and methods of a class:
class Puppy{
int puppyAge;
public getAge( ){
System.out.println("Puppy's age is :" + puppyAge ); return
puppyAge;
}
public static void main(String []args){
/* Object creation */
Puppy my Puppy = new Puppy( "tommy" );
JAVA MODIFIERS:
Like other languages it is possible to modify classes, methods etc by using modifiers. There are
two categories of modifiers.
Access Modifiers : defualt, public , protected, private Non-
access Modifiers : final, abstract, strictfp
INHERITANCE
Inheritance can be defined as the process where one object acquires the properties of another.
With the use of inheritance the information is made manageable in a hierarchical order.
When we talk about inheritance the most commonly used keyword would be extends and
implements. These words would determine whether one object IS-A type of another. By using
these keywords we can make one object acquire the properties of another object.
IS-A Relationship:IS-A is a way of saying : This object is a type of that object. Let us see how the
extends keyword is used to achieve inheritance.
Example code:
public class Animal{
HAS-A relationship:
These relationships are mainly based on the usage. This determines whether a certain class HAS-A
certain thing. This relationship helps to reduce duplication of code as well as bugs.
Lets us look into an example:
public class Vehicle{} public
class Speed{}
public class Van extends Vehicle{ private
Speed sp;
}
This shows that class Van HAS-A Speed. By having a separate class for Speed we do not have
to put the entire code that belongs to speed inside the Van class., which makes it possible to
reuse the Speed class in multiple applications.
return result;
}
The Scope of Variables: The scope of a variable is the part of the program where the variable can be
referenced. A variable defined inside a method is referred to as a local variable.
The scope of a local variable starts from its declaration and continues to the end of the block that
contains the variable. A local variable must be declared before it can be used. A parameter is
actually a local variable. The scope of a method parameter covers the entire method.
You can declare a local variable with the same name multiple times in different non- nesting
blocks in a method, but you cannot declare a local variable twice in nested blocks.
A variable declared in the initial action part of a for loop header has its scope in the
OVERRIDING
If a class inherits a method from its super class, then there is a chance to override the method provided
that it is not marked final.
The benefit of overriding is: ability to define a behavior that's specific to the sub class type.
Which means a subclass can implement a parent calss method based on its requirement.
Example:
class Animal{
void move(){
System.out.println("Dogs can walk and run");
}
}
double a = -191.635;
double b = 43.74; int
c = 16, d = 45;
System.out.printf("The absolute value of %.3f is %.3f%n", a, Math.abs(a));
System.out.printf("The ceiling of %.2f is %.0f%n", b, Math.ceil(b)); System.out.printf("The
floor of %.2f is %.0f%n", b, Math.floor(b)); System.out.printf("The rint of %.2f is %.0f%n",
b, Math.rint(b)); System.out.printf("The max of %d and %d is %d%n",c, d, Math.max(c,
d)); System.out.printf("The min of of %d and %d is %d%n",c, d, Math.min(c, d));
char ch = 'a';
char[] charArray ={ 'a', 'b', 'c', 'd', 'e' }; / an array of chars
Character ch = new Character('a');
Useful Methods in the Character Class
Method Description
boolean isLetter(char ch) Determines whether the specified char value is a
boolean isDigit(char ch) letter or a digit, respectively.
Determines whether the specified char value is white
boolean isW hitespace(char ch)
space.
boolean isUpperCase(char ch) Determines whether the specified char value is
boolean isLowerCase(char ch) uppercase or lowercase, respectively.
char toUpperCase(char ch) Returns the uppercase or lowercase form of the
char toLowerCase(char ch) specified char value.
Returns a String object representing the specified
toString(char ch)
character value— that is, a one-character string.
boolean equalsIgnoreCase( Returns true if and only if the argument is a String object that
String represents the same sequence of character
anotherString) as this object, ignoring differences in case.
Returns the no of character in the String.
Example: String S1= “Shree Jagannath”; int
Len = S1.length();
int length()
Also can be compared by:
if (S1.length == 9)
System.out.println(“ Jai Jagannath”)
jFrame Control:
Provides basic attributes and behaviours of a window. A frame is displayed as a separate window
with its own title bar.
Methods:
void setTitle(): To set title of the current java Frame Form
Example: setTitle("Data Entry Form");
or this.setTitle(“Data Entry Form”);
void setBounds(leftSpc, topSpc, width, height): To set the position of the Form in VDU.
jLable Control:
Allows un-editable text (i.e. that user can’t change) or Icon to be displayd.
Methods:
void setText(String) –To set the Text displayed by the Label. Also HTML is allowed for Swing
components.
Example: jLabel1.setText(“<html><b><u>T</u>wo</b><br>lines</html>”);
Two
lines
jLbael1.setText(“Final Year Investigatory Project”); String
jTextField Control:
It is an input area that allows the user to input & display single line of text in it.
Methods:
void setText(String) –To set the Text displayed by the Text Field.
Example: jTextField1.setText(“Jai Jagannath”);
String getText() –To get the Text displayed by the Text Field.
Example: String S1= jTextField1.getText();
boolean isEditable() –Indicates whether the user can edit the text in the text field or not.
Example: if (jTextField1.isEditable()==true)
boolean isEnable() –Indicates whether the control will responds to the user or not.
Example: if (jTextField1.isEditable()==true)
jPasswordField Control:
It is a type of text field that shows encrypted text.
void setEchoChar(char) –Sets the echo character passed e.g. *, # & etc –the characters
char getEchoChar() –Returnsthe echo character passed e.g. *, # & etc –the characters displayed
instead of the actual character typed by the user.
Example: char encryptChar = jPasswordField1.getEchoChar(‘#’);
char [] getPassword() –Returns the actual text entered in the passsord text field.
Example: String passW = new String (jPasswordField1.getPassword()) ;
if(passW.equals("jagannath"))
JOptionPane.showMessageDialog(this, " Correct Password" );
Methods:
void setText(String) –To set the text displayed by the button. You can use HTML formatting, as
described in Using HTML in Swing Components
Example: jButton1.setText(“<html><b><u>C</u>al</b><br>culate</html>”);
Calculate
jButton1.setText(“Calculate”);
void doClick() or void doClick(int) –Programmatically perform a "click". The optional argument
specifies the amount of time (in milliseconds) that the button should look pressed.
Example: jButton1.doClick();
boolean isEnabled() –Determines whether this component is enabled. Return true if the
component is enabled, false otherwise.
Example: if (jButton1.isEnabled()==true)
jCheckBox Control:
Provides checkbox. Checkboxes are used to allow a user selected multiple choices, e.g.,
Methods:
void setText(String) –To set the Text displayed by the jCheckBox.
Example: jCheckBox1.setText(“Jai Jagannath”);
boolean isEnabled() –Determines whether this component is enabled. Return true if the
component is enabled, false otherwise.
Example: if (jCheckBox1.isEnabled()==true)
jRadioButton Control:
Provides Radio buttons. Radio buttons are option buttons that can be turned on or off. The radio
buttons provides mutually exclusive options. i.e. Select any one among a group.
Methods:
void setText(String) –To set the Text displayed by the jRadioButton.
Example: jRadioButton1.setText(“Jai Jagannath”);
boolean isEnabled() –Determines whether this component is enabled. Return true if the
component is enabled, false otherwise.
Example: if (jRadioButton1.isEnabled()==true)
jPanel Control:
It is a supporting container that cannot be displayed on its own but must be added to another
container. Panels can be added to the content pane of a frame. They help to
jList Control:
it is a list of items from which a selection can be made. From a list, multiple elements can be
selected.
Methods:
void clearSlection() – Clears the selection in the list; after calling this method, the mothod
isSelectionEmpy will return true.
int getMaxSelection() –Returnsthe largest selection in the cell list, or -1if the selection is empty.
int getSelectMinSelection() –Returns the smallest selection in the cel list, or -1if the selection is
empty.
int getSelectedIndex() –Returns the selected index or smallest index among multiple selection.
Example: int ind = jList1.getSelectedIndex();
int [] getSelectedIndices() –Returnsan array of all of the selected indices, in increasing order, or
empty array if nothing is selected.
object getSelectedValue() –Returns the selected value when only a single item is selected in
the List. If multiple item selected then it returns the value at minimum indexes.
Example: String EName = (String) jList1.getSelectedValue();
Object [] getSelectedValues() –Returns an array of all selected values, in increasing order based
on their indices in the list. Or an empty are is return if nothing is selected.
Example: String EName = (String) jList1.getSelectedValue();
boolean isSelectedIndex(int index) –Returns true if the specified index is selected, else false.
Example: if (jList1.isSelectedIndex(ind))
void setSeletedIndex(int Index) –To select a single cell as per specified index.
Example: jLIst.setSelectIndex(2) ;
void setSelectedIndices(int [] indices) –To change the selection to be the set of indices specified by the
given array.
Example: jList.setSelectedIndices(int [] Array OfIndices);
void addItem(Object anObject) – Adds an item ot the item list, in the end of the combo box.
void removeItem(Object item) –Removes specified item from the Combo Box.
Example: jComboBox1.removeAllItems(“Name”);
void setMaximumrowCount(int count) –Sets the number of rows displayed when the combo box
list is dropped down.
PROCESSOR
Pentium 486/PI/PII/PIII/PIV/Core2Due or Higher Processor
MEMORY
Main Memory : 64 MB or More
Secondary Memory : 10 GB or More
NETWORKING [optional]
LAN (for module developments)
INTERNET (for online informations)
SOFTWARE
OPERATING SYSTEM
GUI : Windows 98SE/XP OS or Higher (or any GUI OS)
APPLICATION
Word Processor : MS Word (or any other for documentation) Editor :
NetBean Java
LANGUAGE
Coding Language : Advance Java with JDK 1.6 or higher
BACK-END DBMS
RDBMS : MY SQL 5.1or Advance
DASH
T002 PRAVU PRASAD MISHRA SRIKSHETRA, PURI, ORISSA 90000 D002 1900-05-26
forObj.setTitle("List of orders");
jButton1.setFont(new java.awt.Font("Tahoma", 1, 12)); / NOI18N jButton1.setText("Display/Query
");
jTable1.setModel()
this.setVisible(false);
new MainMenuUI().setVisible(true);
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}
txtTno.setText(tcode);
txtTname.setText(name);
txtTaddress.setText(add);
txtTsalary.setText(" "+sal);
txtTdeptno.setText(dept);
txtTdoj.setText(Tdoj);
txtTno.setText(tcode);
txtTname.setText(name);
txtTaddress.setText(add);
txtTsalary.setText(" "+sal);
txtTdeptno.setText(dept);
txtTdoj.setText(Tdoj);
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}
stmt = con.createStatement(); rs =
stmt.executeQuery(SQL);
txtTno.enableInputMethods(false); while
(rs.next()) {
String tcode = rs.getString("tno");
String name = rs.getString("tname");
String add = rs.getString("taddress");
float sal = rs.getFloat("salary"); String
dept = rs.getString("dept_no"); String
Tdoj = rs.getString("doj");
txtTno.setText(tcode);
txtTname.setText(name);
txtTaddress.setText(add);
txtTSalary.setText(" "+sal);
txtTDeptno.setText(dept);
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
stmt = con.createStatement();
String strSQL = "Update teacher set salary = "+(sal)+",tname ='"+(name)+"',taddress = '"+ (add)+"',
dept_no = '"+(dept)+"', doj = '"+(Tdoj)+"' where tno = '"+(tcode)+"'";
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}
Output Screen after Deletion of the Teacher Record with Sample Data
Entry
stmt = con.createStatement();
DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","admin"); Statement
stmt = null;
ResultSet rs = null;
stmt = con.createStatement(); rs =
stmt.executeQuery(SQL);
txtTno.enableInputMethods(false); while
(rs.next()) {
String tcode = rs.getString("tno");
String name = rs.getString("tname");
String add = rs.getString("taddress");
float sal = rs.getFloat("salary"); String
dept = rs.getString("dept_no"); String
Tdoj = rs.getString("doj");
txtTno.setText(tcode);
txtTname.setText(name);
txtTaddress.setText(add);
txtTSalary.setText(" "+sal);
txtTDeptno.setText(dept);
txtTDoj.setText(Tdoj);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}
// if(sfld.equalsIgnoreCase("TNO")==true)
// String qry = "SELECT * FROM TEACHER;";
// String qry = "SELECT * FROM teacher WHERE "+(sfld)+" "+(ofld)+" "+(cfld)+" ;";
// if(cfld.equalsIgnoreCase(rsObj.getString(1))==true)
// above is to compare object
if(sfld.equalsIgnoreCase("TNO")==true)
{
if((cfld.compareToIgnoreCase((String)rsObj.getString(1))==0) &&
(ofld.equals("=")==true))
tModelObj.addRow(new Object[] {
rsObj.getString(1), rsObj.getString(2),rsObj.getString(3),
rsObj.getString(4),rsObj.getString(5),rsObj.getString(6)});
else if((cfld.compareToIgnoreCase((String)rsObj.getString(1))!=0) &&
ofld.compareTo("=")!=0)
tModelObj.addRow(new Object[] {
rsObj.getString(1), rsObj.getString(2),rsObj.getString(3),
rsObj.getString(4),rsObj.getString(5),rsObj.getString(6)});
}
if(sfld.equalsIgnoreCase("SALARY")==true)
tModelObj.addRow(new Object[] {
rsObj.getString(1), rsObj.getString(2),rsObj.getString(3),
rsObj.getString(4),rsObj.getString(5),rsObj.getString(6)});
}
rsObj.close();
stmt = con.createStatement(); rs =
stmt.executeQuery(SQL);
txtTno.enableInputMethods(false);
while (rs.next()) {
String tcode = rs.getString("tno");
String name = rs.getString("tname");
String add = rs.getString("taddress");
float sal = rs.getFloat("salary"); String
dept = rs.getString("dept_no");
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage()); e.printStackTrace();
}
}
stmt = con.createStatement();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage()); e.printStackTrace();
}
}
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","admin"); Statement stmt =
null;
ResultSet rs = null;
effectively.
USE SCHOOL;
CREATE TABLE TEACHER (TNO char(4) PRIMARY KEY, TNAME varchar(25), TADDRESS
TABLE: TEACHER
DASH
T002 PRAVU PRASAD MISHRA SRIKSHETRA, PURI, ORISSA 90000 D002 1900-05-26
Vidya Bhavan School is working successfully. The code, test plan &
Other documents are used to solve the total process of the system. Any
user can test this project easily but there may be some error that can be
negligible and that will not affect the system or the general user. Any
type of difficulty will be find that should be error free by the system
administrator.
The design of the system is very attractive but time taking or the
MAINTENANCE
INSTALLATION PROCEDURE
The user has to first switch ON the computer then wait for the desktop screen. Then
open the CD drive & copy the folder of this software to the mass storage device of the
PC.
DOCUMENTATION:
The program provides proper documentation with clarity of coding.
MAINTENANCE
CERTIFICATE
“Bharatiya Vidya Bhavans School” under the guidance of Mr. Simit Roy ,
1. Herbert Schildt , Java : the complete reference, Tata MacGraw Hill, 2005
2. Geary David M, Graphic java Mastering the JFC, Addision Wesley, 2006
5. George Reese, Database programming with JDBC and Java, O’Reilly, 2004