[go: up one dir, main page]

0% found this document useful (0 votes)
4 views60 pages

Ayushman Samantaray Final Ip Project SH

Uploaded by

worksoumya34
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views60 pages

Ayushman Samantaray Final Ip Project SH

Uploaded by

worksoumya34
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

BHARATIYA VIDYA BHAVAN

SCHOOL
HALDIA
A
PROJECT DOCUMENTATION
ON

“Teachers’ Information System”


of
BHARATIYA VIDYA BHAVAN
SCHOOL
Submitted by:
AYUSHMAN SAMANTARAY
Class: XII Sci., Roll No:
Under the Guidance of
MR. SIMIT ROY
PGT, BHAVAN’S, HALDIA
Submitted to:
CBSE FOR SSCE 2024-2025

<Page 1 of 57>
CONTENTS

1. Certificate

2. Acknowledgment

3. Overview of Java, HTML & RDBMS


4. Need for the Project

5. Requirements (hardware & Software)


6. Library Files used in the Project

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

14. Data Dictionary


15. Certificate (by External)

16. Bibliography

<Page 2 of 57>
BHARATIYA VIDYA
BHAVAN’S SCHOOL
HALDIA

CERTIFICATE

This is to

certify that AYUSHMAN SAMANTARAY, student of XII ‘Sci.’, BHARATIYA

VIDYA BHAVAN SCHOOL,HALDIA has successfully Completed her project work

on “Teachers’ Data Entry System” of BHARATIYA VIDYA BHAVAN SCHOOL,


st th
under my guidance in a period of 1week from 1 Nov, 2024 to 9 Nov, 2024 in the

Computer Lab of BHARATIYA VIDYA BHAVAN SCHOOL. The project has been

performed in accordance with the requirements of AISSCE, 2024-2025.

Under signed wishes you a happy and bright future.

(Mr. SIMIT ROY) Principal


PGT, Comp. Sc.,Bhavans Bhavans,Haldia

<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

development of this project.

Secondly, I am very much thankful to Smt. Sreosi Kabiraj Chatterjee,

PRINCIPAL,Bharatiya Vidya Bhavan School,Haldia for giving me the

opportunity / independence to develop such Project.

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

who had helped me for the completion of this project report.

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.

Date: 30 November 2024


Place: Haldia AYUSHMAN SAMANTARAY

<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.

NUMERIC INTEGRAL PRIMITIVE TYPE


byte: The byte data type is an 8-bit (1byte) signed two's complement integer. It
has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data
type can be useful for saving memory in large array.
short: The short data type is a 16-bit (2byte) signed two's complement integer.
(minimum value of -32,768 to maximum value of 32,767 (inclusive))
int: The int data type is a 32-bit (4byte) signed two's complement integer.
It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647
(inclusive).
long: The long data type is a 64-bit (8 byte) signed two's complement integer. It
has a minimum value of -9,223,372,036,854,775,808 and a maximum value of
9,223,372,036,854,775,807 (inclusive).

FRACTIONAL PRIMITIVE TYPE


float: The float data type is a single-precision 32-bit (4byte) floating point. double: The
double data type is a double-precision 64-bit (8byte) floating
point.

BOOLEAN PRIMITIVE TYPE


boolean: The boolean data type has only two possible values: true and false. Use
this data type for simple flags that track true/false conditions. This data type represents
one bit of information, but its "size" isn't something that's precisely defined.

CHARACTER PRIMITIVE TYPE


char: The char data type is a single 16-bit (2 byte) Unicode character. It has a
minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive).

STRING DATA TYPE


( The eight primitive data types are: byte, short, int, long, float, double, boolean, and
char. The java.lang.String class represents character strings.

<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
}

The if...else Statement:


An if statement can be followed by an optional else statement, which executes when the
Boolean expression is false.
Syntax:
if(Boolean_expression){
/Executes when the Boolean expression is true
}else{
/Executes when the Boolean expression is false
}

The if...else if...else Statement:


An if statement can be followed by an optional else if...else statement, which is very
usefull to test various conditions using single if...else if statement.
Syntax:
if(Boolean_expression 1){
/Executes when the Boolean expression 1is true
}else if(Boolean_expression 2){
/Executes when the Boolean expression 2 is true
}else if(Boolean_expression 3){
/Executes when the Boolean expression 3 is true
}else {
/Executes when the none of the above condition is true.
}

<Page 6of 57>


Nested if...else Statement:
It is always legal to nest if-else statements, which means you can use one if or else if
statement inside another if or else if statement.
Syntax:
The sy ntax for a nested if...else is as follows:
if(Boolean_expression 1){
/Executes when the Boolean expression 1is true if(Boolean_expression 2){
/Executes when the Boolean expression 2 is true
}
}

The switch Statement:


A switch statement allows a variable to be tested for equality against a list of values. Each
value is called a case, and the variable being switched on is checked for each case.
Syntax:
switch(expression){ case
value :
/Statements break;
/optional
case value :
/Statements break;
/optional
/You can have any number of case statements. default :
/Optional
/Statements
}

Looping Structure: while, do-while, for;


Java has very flexible three looping mechanisms. You can use one of the following three loops:
while Loop
do...while Loop
for Loop

The while Loop:


A while loop is a control structure that allows you to repeat a task a certain number of
times.
Syntax:
while(Boolean_expression)
{
/Statements
}

The do...while Loop:


A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to
execute at least one time.
Syntax:
do {
/Statements
}while(Boolean_expression);

<Page 7of 57>


The for Loop:
A for loop is a repetition control structure that allows you to efficiently write a loop that
needs to execute a specific number of times.
A for loop is useful when you know how many times a task is to be repeated.
Syntax:
for(initialization; Boolean_expression; update)
{
/Statements
}

Enhanced for loop in Java:


As of java 5 the enhanced for loop was introduced. This is mainly used for Arrays.
Syntax:
for(declaration : expression)
{
/Statements
}
Declaration . The newly declared block variable, which is of a type compatible with the
elements of the array you are accessing. The variable will be available within the for block and
its value would be the same as the current array element.
Expression . This evaluate to the array you need to loop through. The expression can be an array
variable or method call that returns an array.
Example:
public class Test {
public static void main(String args[]){ int []
numbers = {10, 20, 30, 40, 50};

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,

The break Keyword:


The break keyword is used to stop the entire loop. The break keyword must be used inside
any loop or a switch statement.
The break keyword will stop the execution of the innermost loop and start executing the
next line of code after the block.
Syntax:
break;

The continue Keyword:

<Page 8of 57>


The continue keyword can be used in any of the loop control structures. It causes the loop
to immediately jump to the next iteration of the loop.
In a for loop, the continue keyword causes flow of control to immediately jump to the
update statement.
In a while loop or do/while loop, flow of control immediately jumps to the Boolean expression.
Syntax:
The sy ntax of a continue is a single statement inside any loop:
continue;

OBJECT ORIENTED CONCEPT OF JAVA:


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.
Methods - A method is basically a behavior. A class can contain many methods. It is in methods where the
logics are written, data is manipulated and all the actions are executed.
Instant Variables - Each object has its unique set of instant variables. An object.s state is created by the
values assigned to these instant variables.

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.

<Page 9of 57>


Note: In certain other languages, methods are referred to as procedures and functions. A method
with a nonvoid return value type is called a function; a method with a void return value type is
called a procedure.
Example: Here is the source code of the above defined method called max(). This method takes
two parameters num1and num2 and returns the maximum between the two:
/** Return the max between two numbers */ public
static int max(int num1, int num2) {
int result;
if (num1> num2) result
= num1;
else
result = num2;

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) {

<Page 10of 57>


for (int i = 0; i < n; i++) System.out.println(message);
}
This would produce following result:
Before swap method, num1is 1and num2 is 2 Inside
the swap method
Before swapping n1is 1n2 is 2 After
swapping n1is 2 n2 is 1
After swap method, num1is 1and num2 is 2

JAVA OBJECTS AND CLASSES


Java is an Object Oriented Language. As a language that has the Object Oriented feature Java
supports the following fundamental concepts: Poly morphism, Inheritance, Encapsulation,
Abstraction, Classes, Objects, Instance, Method, Message Parsing.

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(){
}
}

A class can contain any of the following variable types.


Local variables .variables defined inside methods, constructors or blocks are called local
variables. The variable will be declared and initialized within the

<Page 11of 57>


method and the variable will be destroyed when the method has completed.

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

<Page 12of 57>


to create new objects.
There are three steps when creating an object from a class:
Declaration .A variable declaration with a variable name with an object type. Instantiation
.The 'new' key word is used to create the object.
Initialization .The 'new' keyword is followed by a call o a constructor. This call initializes the
new object.
Example of creating an object is given below:
class Puppy{
public Puppy(String name){
/ This constructor has one parameter, name.
System.out.println("Passed Name is :" + name );
}
public static void main(String []args){
/ Following statement would create an object my Puppy Puppy
my Puppy = new Puppy( "tommy" );
}
}
If we compile and run the above program then it would produce following result:
Passed Name is :tommy

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();

/* Now call a variable as follows */ ObjectReference.variableName;

/* Now you can call a class method as follows */ ObjectReference.MethodName();

Example:
This example explains how to access instance variables and methods of a class:
class Puppy{

int puppyAge;

public Puppy(String name){


/ This constructor has one parameter, name.
System.out.println("Passed Name is :" + name );
}
public setAge( int age ){
puppyAge = age;
}

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" );

<Page 13of 57>


/* Call class method to set puppy's age */ my
Puppy.setAge( 2 );

/* Call another class method to get puppy's age */ my


Puppy.getAge( );

/* You can access instance variable as follows as well */ System.out.println("Variable


Value :" + my Puppy.puppyAge );
}
}
If we compile and run the above program then it would produce following result:
Passed Name is :tommy
Puppy's age is :2 Variable
Value :2

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

Java Access Modifiers/ Access Specifiers:


Java provides a number of access modifiers to set access levels for classes, variables, methods and
constructors. The four access levels are:
1. Package/Default/friendly : Visible to the package. the default. No modifiers are needed.
2. Private: Visible to the class only.
3. Public: Visible to the world.
4. Protected: Visible to the package and all subclasses.
Accessibility of Access Specifier:
Access Specifier Accessible by classes Accessible by classes Accessible by subclasses in Accessible by
in the same in other the same package. i.e. subclasses in other
package packages in case of Inheritance packages
Public Yes Yes Yes Yes
Protected Yes No Yes Yes
Package (default) Yes No Yes No
Private No No No No

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{

<Page 14of 57>


}

public class Mammal extends Animal{


}

public class Reptile extends Animal{


}

public class Dog extends Mammal{


}
Now based on the above example, In Object Oriented terms following are true: Animal is the
superclass of Mammal class.
Animal is the superclass of Reptile class.
Mammal and Reptile are sub classes of Animal class. Dog is
the subclass of both Mammal and Animal classes.

Now if we consider the IS-A relationship we can say: Mammal


IS-A Animal
Reptile IS-A Animal Dog
IS-A Mammal
Hence : Dog IS-A Animal as well

Multiple Inheritance: Multiple inheritance is not allowed in java so it can be implemented by


interface using implements. The implements keyword is used by classes by inherit from
interfaces. Interfaces can never be extended.
Example:
public interface Animal {}

public class Mammal implements Animal{


}

public class Dog extends Mammal{


}

The instanceof Keyword:


Let us use the instanceof operator to check determine whether Mammal is actually an Animal, and dog
is actually an Animal
interface Animal{}

class Mammal implements Animal{} class

Dog extends Mammal{


public static void main(String args[]){
Mammal m = new Mammal();
Dog d = new Dog();
System.out.println(m instanceof Animal); System.out.println(d
instanceof Mammal); System.out.println(d instanceof Animal);
}
}

This would produce following result:


true

<Page 15of 57>


true
true

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.

OVERLOADING METHODS / FUNCTION OVERLOADING


More than one function having same name but different parameter lists within one class is
referred to as method overloading.
Example:
public static double max(double num1, double num2) { if
(num1> num2)
return num1;
else
return num2;
}

public static int max(int num1, int num2) { int


result;
if (num1> num2) result
= num1;
else
result = num2;

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

<Page 16of 57>


entire loop. But a variable declared inside a for loop body has its scope limited in the loop body
from its declaration to the end of the block that contains the variable as shown below:

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{

public void move(){ System.out.println("Animals


can move");
}
}

class Dog extends Animal{ public

void move(){
System.out.println("Dogs can walk and run");
}
}

public class TestDog{

public static void main(String args[]){


Animal a = new Animal(); / Animal reference and object Animal b =
new Dog(); / Animal reference but Dog object

a.move(); / runs the method in Animal class

b.move(); /Runs the method in Dog class


}
}
This would produce following result:
Animals can move Dogs
can walk and run

<Page 17of 57>


Rules for method overriding:
The argument list should be exactly the same as that of the overridden method.
The return type should be the same or a subtype of the return type declared in
the original overridden method in the super class.
The access level cannot be more restrictive than the overridden method's access
level. For example: if the super class method is declared public then the overridding
method in the sub class cannot be either private or public. However the access level
can be less restrictive than the overridden method's access level.
Instance methods can be overridden only if they are inherited by the subclass.
A method declared final cannot be overridden.
A method declared static cannot be overridden but can be re-declared. If a
method cannot be inherited then it cannot be overridden.
A subclass within the same package as the instance's superclass can override any
superclass method that is not declared private or final.
A subclass in a different package can only override the non-final methods declared public
or protected.
An overriding method can throw any uncheck exceptions, regardless of whether the
overridden method throws exceptions or not. However the overridden method should
not throw checked exceptions that are new or broader than the ones declared by the
overridden method. The overriding method can throw narrower or fewer exceptions
than the overridden method.
Constructors cannot be overridden.

Using the super keyword:


When invoking a superclass version of an overridden method the super keyword is used.
class Animal{

public void move(){ System.out.println("Animals


can move");
}
}

class Dog extends Animal{ public


void move(){
super.move(); / invokes the super class method
System.out.println("Dogs can walk and run");
}
}

public class TestDog{


public static void main(String args[]){
Animal b = new Dog(); / Animal reference but Dog object b.move();
/Runs the method in Dog class
}
}
This would produce following result:
Animals can move Dogs
can walk and run

<Page 18of 57>


COMMONLY USED LIBRARIES:
Math Functions java.lang.Math; import
The Math class in the java.lang package provides methods and constants for doing more
advanced mathematical computation. e.g. Math.cos(angle);

import static java.lang.Math.*;


This allows you to invoke the Math class methods by their simple names. For
example: cos(angle);
Note : Using the static import language feature, you don't have to write Math in front of
every math function:

Basic Math Methods


Method Description
double abs(double d) float
abs(float f)
Returns the absolute value of the argument.
int abs(int i)
long abs(long lng)
Returns the smallest integer that is greater than or equal to
double ceil(double d)
the argument. Returned as a double.
Returns the largest integer that is less than or equal to the
double floor(double d)
argument. Returned as a double.
long round(double d) Returns the closest long or int, as indicated by the method's
int round(float f) return type, to the argument.

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));

Here's the output from this program:


The absolute value of -191.635 is 191.635 The
ceiling of 43.74 is 44
The floor of 43.74 is 43
The rint of 43.74 is 44
The max of 16 and 45 is 45
The min of 16 and 45 is 16

Exponential and Logarithmic Methods


The next table lists exponential and logarithmic methods of the Math class.
Exponential and Logarithmic Methods
Method Description
double pow( double base, double Returns the value of the first argument raised to the
exponent ) power of the second argument.
double sqrt(double d) Returns the square root of the argument.

<Page 19of 57>


Random Numbers:
The random() method returns a pseudo-randomly selected number between 0.0 and
1.0. The range includes 0.0 but not 1.0. In other words: 0.0 <= Math.random() < 1.0.
To get a number in a different range, you can perform arithmetic on the value returned by the
random method. For example, to generate an integer between 0 and 9, you would write: int
number = (int)(Math.random() * 10);

Character Functions: import java.lang.Character; To call


character library functions.

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.

Manipulating Characters in a String:


The String class has a number of methods for examining the contents of strings, finding characters or
substrings within a string, changing case, and other tasks.

The substring Methods in the String Class


Method Description
Returns a new string that is a substring of this string. The first
String substring(int beginIndex, integer argument specifies the index of the firs character. The
int endIndex) second integer argument is the index of
the last character + 1.
Returns a new string that is a substring of this string. The
String substring(int integer argument specifies the index of the first character.
beginIndex) Here, the returned substring extends to the
end of the original string.
Returns a copy of this string with leading and trailing
String trim()
white space removed.
Returns a copy of this string converted to lowercase or
String toLowerCase() String
uppercase. If no conversions are necessary, these
toUpperCase()
methods return the original string.
You can also use the concat() method with string literals, as
concat() in:
Example1: string1.concat(string2);
<Page 20of 57>
This returns a new string that is string1with string2 added to it
at the end.
Example2: "Jai Pravu".concat("Jagannath"); Also +
operator can be used to concatenate: String S1=
String1+ String2+any Object;
But using + operator concatenate it can be a mixture o any
object and string so we need to convert the mixtur
to string using string() function
Returns a string that contains the character sequence in the
builder or mixture of any Object, characters and Strings.
tostring() Int p=908;
String St = integer.tostring(p);

Compares two strings lexicographically. Returns an integer


int compareTo( String indicating whether this string is greater than (result is > 0),
anotherString ) equal to (result is = 0), or less than (result is < 0) the argument.

Compares two strings lexicographically, ignoring differences


int
in case. Returns an integer indicating whether this string is
compareToIgnoreCase( String str
greater than (result is > 0), equal to (result is = 0), or less than
)
(result is < 0) the argument

Returns true if and only if the argument is a String object that


boolean equals(Object anObject) represents the same sequence of character as this object.
Example: if(String1.equals(jCombo.getSelected()))

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”)

CONCEPT OF JAVA - PACKAGES


Packages are used in Java in-order to prevent naming conflicts, to control access, to make
searching/locating and usage of classes, interfaces, enumerations and annotations easier etc.
A Package can be defined as a grouping of related types (classes, interfaces,
enumerations and annotations) providing access protection and name space
management.
Some of the existing packages in Java are:: java.lang -
bundles the fundamental classes
java.io - classes for input , output functions are bundled in this package
Programmers can define their own packages to bundle group of classes/interfaces etc. It is a good
practice to group related classes implemented by you so that a

<Page 21of 57>


programmers can easily determine that the classes, interfaces, enumerations, annotations are
related.
Example:
Put an interface in the package animals:
/* File name : Animal.java */
package animals;

interface Animal { public


void eat(); public void
travel();
}
Now put an implementation in the same package animals:
package animals;

/* File name : MammalInt.java */


public class MammalInt implements Animal{

public void eat(){


System.out.println("Mammal eats");
}

public void travel(){


System.out.println("Mammal travels");
}

public int noOfLegs(){ return


0;
}

public static void main(String args[]){


MammalInt m = new MammalInt();
m.eat();
m.travel();
}
}

JAVA GUI TOOLKIT


A GUI in Java is created with at least three kinds of Objects:
Components –(GUI Object Controls like TextBox, Labels, Menu & etc.)
Events Handler–(Occurrence of an activity / do the work for the user if the event
occures)
Event Listener –(get notified about the events and responds to them)

This table lists Swing components with their specialized listeners


Component Listener
document, list windo
actio caret change undoable item other
selection w

<Page 22of 57>


edit
button
check box
color chooser
combo box
dialog
frame
list list data
menu menu
menu
key
menu item menu
drag
mouse
option pane
password fiel
radio button
spinner
table
model
table
table column
model
cell
editor
text area
text field
toggle button

BASIC GRAPHICAL CONTROLS OF SWING:

import javax.swing.*; to utilize all the following Object Controls

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 dispose(): To Close the current Java Frme Form


Example:this.dispose();
or dispose();

void setVisible(Boolean): To show or hide the form.


Example:Form2 Mob = new Form2(); / first create the form instance
Mob.setTitle("title text"); / to change the form title Mob.setVisible(true); / to
show the form2 in the VDU

void setBounds(leftSpc, topSpc, width, height): To set the position of the Form in VDU.

<Page 23of 57>


Example: Form2 form2Obj = new Form2();
form2Obj.setBounds(850, 200,350, 320); form2Obj.setVisible(true);

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

getText() –To get the Text displayed by the Label.


Example: String S1= jLabel1.getText();

void setIcon(Icon) –To Set the Icon Image to the Label.


jLabel3.setIcon(new ImageIcon("D: \JAVAGUI \IMAGE \RESIZE \taurus.jpg"));

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)

void setIcon(Icon) –To Set the Icon Image to the Label.


Example: jTextField1.setIcon(new ImageIcon("D: \JAVAGUI \IMAGE \taurus.jpg"));

void setEditable(boolean) –Allow the text field to be editable.


Example: jTextField1.setEditable(false) ;

void selectAll() –Selects all character in the text field.


Example: jTextField1.selectAll() ;

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

<Page 24of 60>


displayed instead of the actual character typed by the user.
Example: jPasswordField1.setEchoChar(‘#’);

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" );

void selectAll() –Selects all character in the password text field.


Example: jTextField1.selectAll() ;

jButton Control (PUSH BUTTON):


Provides button capabilities, An Action Event is generated when button is pushed.

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”);

String getText() –To get the text displayed by the button.


Example: String S1= jButton1.getText();

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();

void setSelected() –Sets the state of the Button selected or deselected.


Example: jButton1.setEnabled(true);
jButton2.setEnabled(false);

void setEnabled() –Sets the state of the Button Enabled or Disabled.


Example: jButton1.setEnabled(false);
jButton1.setEnabled(true);

boolean isSelected() –Returns true if the button is selected, false otherwise.


Example: if (jButton1.isSelected()==true)

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.,

<Page 25of 60>


a student can select 5 subjects out of 17 subject-choices. A check box showsan X in box in front of
it when selected.

Methods:
void setText(String) –To set the Text displayed by the jCheckBox.
Example: jCheckBox1.setText(“Jai Jagannath”);

String getText() –To get the Text displayed by the jCheckBox.


Example: jLabel1.setText(jCheckBox1.getText());

boolean isSelected() –Returns true if the jCheckBox is selected, false otherwise.


Example: if (jCheckBox1.isSelected()==true)

boolean isEnabled() –Determines whether this component is enabled. Return true if the
component is enabled, false otherwise.
Example: if (jCheckBox1.isEnabled()==true)

void setSelected() –Sets the state of the CheckBox selected or deselected.


Example: jCheckBox1.setSelected(true);

void setEnabled() –Sets the state of the CheckBox Enabled or Disabled.


Example: jCheckBox1.setEnabled(false);
jCheckBox1.setEnabled(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”);

String getText() –To get the Text displayed by the jRadioButton1.


Example: jLabel1.setText(jRadioButton1.getText());

boolean isSelected() –Returns true if the jRadioButton1is selected, false otherwise.


Example: if (jRadioButton1.isSelected()==true)

boolean isEnabled() –Determines whether this component is enabled. Return true if the
component is enabled, false otherwise.
Example: if (jRadioButton1.isEnabled()==true)

void setSelected() –Sets the state of the jRadioButton selected or deselected.


Example: jRadioButton1.setSelected(true);

void setEnabled() –Sets the state of the jRadioButton Enabled or Disabled.


Example: jRadioButton1.setEnabled(false);
jRadioButton1.setEnabled(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

<Page 26of 60>


organize the components in a GUI.

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))

boolean isSelectionEmpty() –Returns true if nothing 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 setSelectedvalue(Object anObject, boolean shouldScroll) –Select the specified item-


Object from the list. Its parameters include.
(i) anObject –the object to select.
(ii) shouldScroll –true if the list should scroll to display the selected object, if one
exist; otherwise false.

<Page 27of 60>


jComboBox Control:
It provides a drop down list of items from which a selection can be made or new items can be
added. It is a combination of text field and a list.

void addItem(Object anObject) – Adds an item ot the item list, in the end of the combo box.

Object getItemAt(int index) –Returns item at the specified index.

int getItemCount() –Returns the number of items in the Combo Box.


Example: int N = jComboBox1.getItemCount();

int getSelectedIndex() –Returns the index of the selected item.


Example: int ind = jComboBox1.getSelectedIndex();

object getSelectedValue() –Returns the selected Item as an Object Example:


String Desig = jComboBox1.getSelectedItem().toString();

void removeAllItems() –Removes all items from the Combo Box.


Example: jComboBox1.removeAllItems();

void removeItem(Object item) –Removes specified item from the Combo Box.
Example: jComboBox1.removeAllItems(“Name”);

void removeItemAt(int Index) –Removes the Item at the specified Index.


Example: DefaultComboBoxModel cModel = (DefaultComboBoxModel)
jComboBox1.getModel();
cModel.removeElementAt(ind);

void setEditable(boolean value) –Specifies combo text editable or not.

void setSelectedIndex(int Index) –Selects the item at specified index.

void setSelectedItem(Object item) –Select the specified item.

void setMaximumrowCount(int count) –Sets the number of rows displayed when the combo box
list is dropped down.

NEED FOR THE PROJECT

“Teacher Data Entry System” of

<Page 28of 60>


Bharatiya Vidya Bhavan School

This project is developed by using various software methodologies,


involving the Object Oriented Programming approach to automate the
“Teachers’ Data Entry System”. This is an application for the computer
controlled “Teachers’ Data Entry System” making the task easier in the
“Bharatiya Vidya Bhavan School”.

Our project aims at modeling of the computer software for the


navigation of computer controlled environment to fulfill the “Teachers’
Data Entry System” transactions like Teacher’s Information Entry,
Teacher’s Data Modification/Update, Teacher’s Record Delete, Teacher’s
Record Query and Teacher’s Net Salary Calculation and etc. as
requirements in the Teachers’ Data Entry of Bharatiya Vidya Bhavan
School.

Hence, it can further enhance to incorporate the Teachers’ Data


Entry System jobs easier using computer technology.

<Page 29of 60>


REQUIREMENTS
HARDWARE

PROCESSOR
Pentium 486/PI/PII/PIII/PIV/Core2Due or Higher Processor

MEMORY
Main Memory : 64 MB or More
Secondary Memory : 10 GB or More

OTHER PERIPHERALS [optiona]


Printer (for Documentation using hardcopy)

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

DATABASE USED IN THE PROJECT


Database Name: SCHOOL Table
names :TEACHER

Table contents as Sample Records:


TNO TNAME TADDRESS SALARY DEPT_NO DOJ

T001 SHREE JAGANNATH SRIMANDIR, PURI, ORISSA 80000 D001 1900-09-09

DASH

T002 PRAVU PRASAD MISHRA SRIKSHETRA, PURI, ORISSA 90000 D002 1900-05-26

<Page 30of 60>


LIBRARIES FILES
USED IN THE PROJECT

import javax.swing.*; - For Swing Controls

import javax.swing.ImageIcon; - For Image Icons

import java.awt.Color; - For Color

import javax.swing.JoptionPane; - Java Dialog

import java.io.*; - Input Output Functions import

java.awt.Font; - For Font manipulation

import javax.swing.DefaultComboBoxModel; - To Create combo box models import

javax.swing.table.*; - To use Table control object in the project import

javax.swing.DefaultListModel; - To create java List models

import java.lang.Math; - To use arithmetic Library Functions import

java.lang.String; - To use String Library Functions

import java.sql.Connection; - To create connection object for JDBC import

java.sql.DriverManager; - To implement JDBC Driver Manager

import java.sql.Statement; - To create SQL statement Object to execute query. import

java.sql.ResultSet; - To create Result set object to store records.

import java.sql.*; - All functions/Object related for JDBC. import


javax.swing.JScrollPane; - for java Scroll panels

<Page 31of 60>


CLASSES & OBJECTS
USED IN THE PROJECT

class MenuTeacherUI - For Main Menu & First Screen

class AddTeach - For Teacher’s Detail Entry

class ModTeacherUI - For Teacher Modification & Display

class NetSalUI - For Teacher Net Salary Calculation

class QueryTeach- For Teacher’s Details Query class

DelTeachUI - For Teacher’s Record Delete

<Page 32of 60>


FUNCTIONS
USED IN THE
PROGRAM
All library functions used related to the control objects no user defined objects are used for the
project.

Some library function / control object methods are follows:

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);

jTable Manipulation Functions


DefaultTableModel Tmodel = (DefaultTableModel) jTable1.getModel(); int
rows = Tmodel.getRowCount();
Tmodel.removeRow(0);

JOptionPanel Message Dialog box JOptionPane.showMessageDialog(this,


e.getMessage());

Functions Connect to My SQL database Class.forName("com.mysql.jdbc.Driver").newInstance();


Connection con = (Connection) DriverManager.getConnection("jdbc:mysql: /
localhost:3306/sports","root","admin");

Create SQL statement and execute query. Statement


stmt = con.createStatement(); ResultSet rs =
stmt.executeQuery(query); rs.next() / jump to next
record
String Ordno = rs.getString("Orderno");
rsltObj.next() - moves the cursor (i.e. record control) forward in a result set by one row/record
rsltObj.first() - moves the cursor (i.e. record control) in a result set to first row/record
rsltObj.last() - moves the cursor (i.e. record control) in a result set to last row/record
rsltObj.relative(int N_no_of_rows) - moves the cursor (i.e. record control) in a result set
relatively to N no of row[s]/record[s] forward from the current record/row position.
rsltObj.absolute(int row_no) - moves the cursor (i.e. record control) in a result set to the
particular row/record no.
rsltObj.getRow() - Returns the current cursor position or particular row/record no. rsltObj.close(); -
To close result set resource of the database connectivity

<Page 33of 60>


stmtObj.close(); - To close statement resource of the database connectivity connObj.close(); - To
close connection resource of the database connectivity

<Page 34of 60>


JAVA SOURCE
CODE OF THE
PROJECT
Source code in the Command Buttons :

private void mnuAddActionPerformed(java.awt.event.ActionEvent evt) {


this.setVisible(false);
new AddTeach().setVisible(true);
}

private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
}

private void formWindowGainedFocus(java.awt.event.WindowEvent evt)


{
new MenuTeacherUI().getMaximumSize(); new
MenuTeacherUI().setSize(200, 200);
}

private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {


System.exit(0);
}

private void mnuModActionPerformed(java.awt.event.ActionEvent evt)


{
this.setVisible(false);
new ModTeachUI().setVisible(true);
}

private void mnuDelActionPerformed(java.awt.event.ActionEvent evt) {


this.setVisible(false);
new DelTeachUI().setVisible(true);
}

private void mnuNetSalActionPerformed(java.awt.event.ActionEvent evt)


{
this.setVisible(false);
new NetSalUI().setVisible(true);
}

private void mnuExitActionPerformed(java.awt.event.ActionEvent evt)


{
System.exit(0); // TODO add your handling code here:
}

private void mnuQueryActionPerformed(java.awt.event.ActionEvent evt)


{
this.setVisible(false);
new QueryTeach().setVisible(true); // TODO add your handling code here:

<Page 35of 60>


}

Teacher Data Entry Form–Three

Source code in the Command Buttons :

private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) { 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;
String SQL = "SELECT * FROM teacher";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next()) {
System.out.println(rs.getString("tname") + " : " + rs.getString("taddress"));
}

String tcode = txtTno.getText(); String


name = txtTname.getText(); String add
= txtTaddress.getText();
double sal = Double.parseDouble(txtTsalary.getText()); String
dept = txtTdeptno.getText();
String Tdoj = txtTdoj.getText();

<Page 36of 60>


System.out.print("Insert new record : ");String strSQL = "INSERT INTO
teacher(tno,tname,taddress,salary,dept_no,doj)VALUES('"+(tcode)+"','"+(name)+"','"+(add)+"',"+(sal)
+",'"+(dept)+"','"+(Tdoj)+"')";
int rowsEffected = stmt.executeUpdate(strSQL);
System.out.println(rowsEffected + " rows effected");

} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}

private void btnClearActionPerformed(java.awt.event.ActionEvent evt)


{
// TODO add your handling code here:
txtTno.setText("");
txtTname.setText("");
txtTaddress.setText("");
txtTsalary.setText("");
txtTdeptno.setText("");
txtTdoj.setText("");
}

private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {


this.setVisible(false);
new MenuTeacherUI().setVisible(true);
}

private void btnMFirstActionPerformed(java.awt.event.ActionEvent evt)


{
// TODO add your handling code here:
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;
String SQL = "SELECT * FROM teacher";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
rs.first();
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);

<Page 37of 60>


} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt)


{
// TODO add your handling code here:
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;

String SQL = "SELECT * FROM teacher";


stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
rs.last();
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();
}
}

<Page 38of 60>


Output Screen of Update Data with Sample Data Entry–Five

Source code in the Command Buttons :

private void jList1MouseClicked(java.awt.event.MouseEvent evt) { 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;
String MTno = (String) jList1.getSelectedValue(); MTno
= MTno.substring(0, 4).trim();
String SQL = "SELECT * FROM teacher where tno = '"+(MTno)+"'";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);

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);

<Page 39of 60>


txtTDoj.setText(Tdoj);
}

} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}

private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt)


{
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;

stmt = con.createStatement();

String tcode = txtTno.getText(); String


name = txtTname.getText(); String add
= txtTaddress.getText();
double sal = Double.parseDouble(txtTSalary.getText()); String
dept = txtTDeptno.getText();
String Tdoj = txtTDoj.getText();

String strSQL = "Update teacher set salary = "+(sal)+",tname ='"+(name)+"',taddress = '"+ (add)+"',
dept_no = '"+(dept)+"', doj = '"+(Tdoj)+"' where tno = '"+(tcode)+"'";

int rowsEffected = stmt.executeUpdate(strSQL); if


(rowsEffected == 0)
JOptionPane.showMessageDialog(this, "Record does not exists"); else
JOptionPane.showMessageDialog(this,"Record Updated");

} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}

private void btnClearActionPerformed(java.awt.event.ActionEvent evt)


{
// TODO add your handling code here:
txtTno.setText("");
txtTname.setText("");
txtTaddress.setText("");
txtTDeptno.setText("");
txtTSalary.setText("");
txtTDoj.setText("");
}

<Page 40of 60>


private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
new MenuTeacherUI().setVisible(true);
}

private void formWindowGainedFocus(java.awt.event.WindowEvent evt)


{
DefaultListModel dModel = (DefaultListModel) jList1.getModel(); txtTno.enableInputMethods(false);
dModel.clear();
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;

String SQL = "SELECT * FROM teacher";


stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next()) {
String ntNo = rs.getString("tno"); String
ntName = rs.getString("tname");
dModel.addElement(ntNo + " - " + ntName);
}
jList1.setModel(dModel);
con.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}

Output Screen after Deletion of the Teacher Record with Sample Data
Entry

<Page 41of 60>


private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
new MenuTeacherUI().setVisible(true);
}

private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt)


{
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;

stmt = con.createStatement();

String tcode = txtTno.getText(); String


name = txtTname.getText(); String add
= txtTaddress.getText();
double sal = Double.parseDouble(txtTSalary.getText()); String
dept = txtTDeptno.getText();
String Tdoj = txtTDoj.getText();
String strSQL = "delete from teacher where tno = '"+(tcode)+"'"; int
rowsEffected = stmt.executeUpdate(strSQL);
if (rowsEffected == 0)
JOptionPane.showMessageDialog(this, "Record does not exists"); else
JOptionPane.showMessageDialog(this, "Record Deleted");
System.out.println(rowsEffected + " rows effected");

<Page 42of 60>


} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}

private void jList1MouseClicked(java.awt.event.MouseEvent evt) { 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;

String MTno = (String) jList1.getSelectedValue(); MTno


= MTno.substring(0, 4).trim();

String SQL = "SELECT * FROM teacher where tno = '"+(MTno)+"'";


stmt = con.createStatement();
rs = stmt.executeQuery(SQL);

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();
}
}

private void formWindowGainedFocus(java.awt.event.WindowEvent evt)


{
DefaultListModel dModel = (DefaultListModel) jList1.getModel();
// Method to add elements into jList1 control
dModel.clear();
txtTno.enableInputMethods(false);
try {

<Page 43of 60>


Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","admin"); Statement
stmt = null;
ResultSet rs = null;

String SQL = "SELECT * FROM teacher";


stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next()) {
String ntNo = rs.getString("tno"); String
ntName = rs.getString("tname");
dModel.addElement(ntNo + " - " + ntName);
}
jList1.setModel(dModel);
con.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}

Output Screen in Query of the Teacher Record Sample Data

<Page 44of 60>


Source code in the Command Buttons :
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
DefaultTableModel tModelObj = (DefaultTableModel)jTable1.getModel(); int
rows = jTable1.getRowCount();
if(rows>0)
for(int i=0; i<rows; i++) {
tModelObj.removeRow(0);
}
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)


{
DefaultTableModel tModelObj = (DefaultTableModel)jTable1.getModel(); try{
Class.forName("java.sql.Driver");
Connection connObj = DriverManager.getConnection("jdbc:mysql://localhost/
school","root","admin");
Statement stmtObj=connObj.createStatement(); String sfld
= (String)jComboBox1.getSelectedItem(); String ofld =
(String)jComboBox2.getSelectedItem(); String cfld =
(String)jTextField1.getText();

// if(sfld.equalsIgnoreCase("TNO")==true)
// String qry = "SELECT * FROM TEACHER;";

String qry = "SELECT * FROM teacher WHERE "+(sfld)+" "+(ofld)+" "+(cfld)+";";

// String qry = "SELECT * FROM teacher WHERE "+(sfld)+" "+(ofld)+" "+(cfld)+" ;";

ResultSet rsObj = stmtObj.executeQuery(qry);


while(rsObj.next()) {

// 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();

<Page 45of 60>


stmtObj.close();
connObj.close();
} catch(Exception eObj){
JOptionPane.showMessageDialog(null, "Error in Connectivity...!!");
}
}

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)


{
this.setVisible(false);
new MenuTeacherUI().setVisible(true);
}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt)


{
DefaultTableModel tModelObj = (DefaultTableModel)jTable1.getModel(); try{
Class.forName("java.sql.Driver");
Connection connObj = DriverManager.getConnection("jdbc:mysql://localhost/
school","root","admin");
Statement stmtObj=connObj.createStatement();
//String qry = "SELECT * FROM EMP WHERE "+sfld+ofld+cfld+";";
String qry = "SELECT * FROM teacher;";
ResultSet rsObj = stmtObj.executeQuery(qry);
while(rsObj.next()) {
tModelObj.addRow(new Object[] {
rsObj.getString(1), rsObj.getString(2),rsObj.getString(3),
rsObj.getString(4),rsObj.getString(5),rsObj.getString(6)});
}
rsObj.close();
stmtObj.close();
connObj.close();
} catch(Exception eObj){
JOptionPane.showMessageDialog(null, "Error in Connectivity...!!");
}
}

<Page 46of 60>


NET SALARY CALCULATING SCREEN AFTER CALCULATION

private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {


this.setVisible(false);
new MenuTeacherUI().setVisible(true);
}

private void jList1MouseClicked(java.awt.event.MouseEvent evt) { 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;

String MTno = (String) jList1.getSelectedValue(); MTno


= MTno.substring(0, 4).trim();

String SQL = "SELECT * FROM teacher where tno = '"+(MTno)+"'"; stmt


= con.createStatement();
rs = stmt.executeQuery(SQL);

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");

<Page 47of 60>


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();
}
}

private void btnNetSalActionPerformed(java.awt.event.ActionEvent evt) { 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;

stmt = con.createStatement();

String tcode = txtTno.getText(); String


name = txtTname.getText(); String add =
txtTaddress.getText();
double sal = Double.parseDouble(txtTSalary.getText()); String
dept = txtTDeptno.getText();
String Tdoj = txtTDoj.getText();
double netSal = 0; // Initializing the net salary
double da = 0, hra = 0, deduction = 0; deduction
= sal * 0.1;

if (sal <= 12000) {


da = sal * 0.15;
hra = sal * 0.2;
} else if ((sal > 12000) && (sal <= 16000)) {
da = sal * 0.2;
hra = sal * 0.3;
} else if ((sal > 16000) && (sal <= 20000)) {
da = sal * 0.2;
hra = sal * 0.4;
} else if ((sal > 20000) && (sal <= 25000)) {
da = sal * 0.3;
hra = sal * 0.4;
} else if ((sal > 25000) && (sal <= 35000)) {
da = sal * 0.3;
hra = sal * 0.45;
} else if (sal > 35000) {
da = sal * 0.35;
hra = sal * 0.5;
}

<Page 48of 60>


netSal = (sal + da + hra) - deduction;
txtNet.setText(Double.toString(netSal));

} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage()); e.printStackTrace();
}
}

private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {


// Creating a ListModel object dModel to perform DefaultListModel
// method operations
DefaultListModel dModel = (DefaultListModel) jList1.getModel();
// Method to add elements into jList1 control
dModel.clear();
txtTno.enableInputMethods(false);

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;

String SQL = "SELECT * FROM teacher";


stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
// Adding teacher no. (Tno) and teacher name (tname) into JList box. while
(rs.next()) {
String ntNo = rs.getString("tno"); String
ntName = rs.getString("tname");
dModel.addElement(ntNo + " - " + ntName); // Tno and tname
}
jList1.setModel(dModel);
con.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage()); e.printStackTrace();
}

<Page 49of 60>


TESTING OF THE PROGRAM

The program runs very well and it produces the desired

output as expected by me. This Program is an easy and

excellent way for the Teacher Data transactions in

Bharatiya Vidya Bhavan School.

It perfectly stores the information of all the current and

previous Details of the teachers with accurately and

effectively.

<Page 50of 60>


SAMPLE DATABASE USED IN TEST

SCHOOL DATABASE FOR TEACHERS PROJECT IN IP

DROP database if exists SCHOOL;

CREATE database SCHOOL;

USE SCHOOL;

CREATE TABLE TEACHER (TNO char(4) PRIMARY KEY, TNAME varchar(25), TADDRESS

varchar(30), SALARY float, DEPT_NO char(4), DOJ date);

TABLE: TEACHER

TNO TNAME TADDRESS SALARY DEPT_NO DOJ

T001 SHREE JAGANNATH SRIMANDIR, PURI, ORISSA 80000 D001 1900-09-09

DASH

T002 PRAVU PRASAD MISHRA SRIKSHETRA, PURI, ORISSA 90000 D002 1900-05-26

T003 ANANTA KUMAR SEET BALESWAR, ORISSA 55000 D002 1998-02-28

T004 NABAKISHORE SETHI JAGATSINGPUR, ORISSA 33000 D004 2007-09-05

T005 BABURAM JENA BHADRAK, ORISSA 32000 D004 2007-10-15

<Page 51of 60>


OUTPUT OF THE PROJECT
Output Screen of Teacher Data Entry Form

Output Screen of Teacher Data Entry with Sample Data Entry

<Page 52of 60>


Output Screen of Update Data with Sample Data Entry

Output Screen after Update Data with Sample Data Entry

<Page 53of 60>


Output Screen after Deletion of the Teacher Record with
Sample Data Entry

Output Screen in Query of the Teacher Record Sample Data

<Page 54of 60>


NET SALARY CALCULATING SCREEN BEFORE CALCULATION

NET SALARY CALCULATING SCREEN AFTER CALCULATION

<Page 55of 60>


CONCLUSIONS

All the process of this “Teachers’ Data Entry System” of Bharatiya

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

system is very user friendly.


- Maintenance: The maintenance is very easy not so risky.

- Reliability: The system’s reliability is perfect.

- Operation: This process involved in the system is error free.

- Security: The security is average but it can be increased by


maintaining.

- Safety: There is Security provision for maintaining the records, so, it


is a safety system.

- Cost: The cost of developing & validating the system reliability is


very less.

- Time consume: The system is very less time consuming for

<Page 56of 60>


updating, entering the data & searching the data.

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

The Software provides a very user-friendly environment/coding for its maintenance as


per the requirement in the place of installation. Also, can be

further developed as per modification required by the organisation.

<Page 57of 60>


BHARATIYA VIDYA BHAVAN SCHOOL
HALDIA

DEPARTMENT OF INFORMATICS PRACTICES

CERTIFICATE

This is to certify that AYUSHMAN SAMANTARAY , Student of Class

XII Sci., Informatics Practices. of BHARATIYA VIDYA BHAVAN

SCHOOL has developed the project “Teachers’ Data Entry System” of

“Bharatiya Vidya Bhavans School” under the guidance of Mr. Simit Roy ,

PGT, Computer Science of Bharatiya Vidya Bhavans School .

As a partial fulfillment of the academic curriculum, they have worked on

this project successfully.

External Examiner Internal Examiner


Date: Date:

<Page 58of 60>


<Page 59of 60>
BIBLIOGRAPHY

JAVA PROGRAMMING LANGUAGE REFERENCE:

1. Herbert Schildt , Java : the complete reference, Tata MacGraw Hill, 2005

2. Geary David M, Graphic java Mastering the JFC, Addision Wesley, 2006

3. Informatics Pracites, by Sumata Arora

RELATIONAL DATABASE MANAGEMENT SYSTEM:

4. Lerry Ulman, MYSQL Database, Pearson Education, 2008

5. George Reese, Database programming with JDBC and Java, O’Reilly, 2004

6. DATABASE PRIMER, Adison Wesley by C.J. Data.

7. UNDERSTANDING SQL, BPB Publications by Martin Gruber.

8. CROSS REFERENCE HANDBOOK, First Authorised Asian Edition 93,

Tech. Publications Pvt. Ltd by Sheldon M. Dunn Xbase.

------ END -----

<Page 60of 60>

You might also like