gyan techno solution -...
TRANSCRIPT
GYAN TECHNO SOLUTION
601B ADARSH NAGAR NEAR AJAY GARMENT
ROHTAK HARYANA
A TRAINING REPORT
ON
CORE JAVA
SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS
FOR THE AWARD OF THE DEGREE OF
BACHELOR OF TECHNOLOGY (Information Technology)
SUBMITTED TO
MAHARSHI DAYANAND UNIVERSITY ROHTAK
SUBMITTED BY Name of Student User-ID
SHUBHAM SAINI 11IT055
025-06-13 to 30-07-13
THE TECHNOLOGICAL INSTITUTE OF TEXTILE amp SCIENCES
BHIWANI HARYANA
DECLARATION
I SHUBHAM SAINI bearing Roll No 11IT055 a bonafide student of The Technological
Institute of Textile amp Sciences would like to declare that the project titled ldquoReport on Core-
Javardquo
A partial fulfillment of BY BACHELOR OF TECHNOLOGY Degree course of MDU
UNIVERSITY is my original work in the year 2013 under the guidance of Mrs Satvika
Assistant Professor of the Department of Information Technology
DATE NAME
ROLL NO 11IT055 SHUBHAM SAINI
PLACE
ACKNOWLEDGEMENT
I would like to express my gratitude to all those who gave me helping hand in completion this
term paper I want to thank my teacher Raj Kumar Sharma for helping me whenever I needed it
the most My friends have also supported me in my work I want to thank them all for their
help support interest and valuable hints
I am extremely thankful to Asstt Prof DrMukesh Sharma HOD Computer Science amp IT The
Technological Institute of Textile amp Sciences Bhiwani for valuable suggestions and
encouragement
Signature of Student
SHUBHAM SAINI
CERTIFICATE
I hereby certify that I have completed the Six weeks Trainingin partial fulfilment of the
requirements for the award of Bachelor of Technology in Information Technology I did my
training in ―Gyan Techno Solution at Rohtak Haryana from 25-06-13 to 30-07-13
The matter presented in this Report has not been submitted by me for the award of any
other degree elsewhere
Signature of Student
SHUBHAM SAINI (11IT055)
Signatures
Examined by (Concerned Faculty)
HOD Department of Computer Engineering amp Information Technology
TABLE OF CONTENTS
1 Introduction
11 What is JAVA
12 Versions of JAVA
13 The Birth Of Modern Programming
14 Creation of Java
15 About Java
16 Features of Java
17 Java Architecture
18 A Simple Java Application
19 Java Data Types
110 Operators in Java
111 Javalsquos Selection Statements
112 Inheritance
113 Exception Handing
114 Multithreading
115 Applets
116 Garbage Collector
117 Constructors
2 Project Work
21 Technology Use
22 Java Platform
23 Introduction to Project
24 General Description
25 Functional Requirements
1 INTRODUCTION TO JAVA
11 What is Java
Java is a computer programming language that is concurrent class-based object-oriented and
specifically designed to have as few implementation dependencies as possible It is intended to
let application developers write once run anywhere (WORA) meaning that code that runs on
one platform does not need to be recompiled to run on another Java applications are
typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM)
regardless of computer architecture
JAVA is related to C++ which is a direct
descendant of C Much of the character of java is
inherited from these two languages From Cjava
derives its syntaxMany of javalsquos object oriented
features were influenced by C++In factseveral of
javalsquos defining characteristics come from or is
responses toits predecessorsMoreover the creation
of java was deeply rooted in the process of
refinement and adaption
12 Versions of Java
JDK Alpha and Beta(1995)
JDK 10(1996)
JDK 11(1997)
J2SE 12(1998)
J2SE 13(2000)
J2SE 14(2002)
J2SE 50(2004)
J2SE(2006)
JAVA SE 7(2011)
13 The Birth of Modern Programming
131 C The creation of C was a direct result of the need for a structured efficienthigh-level
language that could replace assembly code when creating system programs As you probably
know when a computer language is designed trade-offs are often made such as the following
Ease of use versus power
Safety versus efficiency
Rigidity versus extensibility
132 C++ The Next Step
Since C is a successful and useful programming language you might ask why need for
something else existed The answer is Complexity Throughout the history of programmingthe
increasing complexity of programs has driven the need for better ways to manage that
complexity C++ is a response to that need C++ has a features of OOPSOOP is programming
methodology that helps organize complex programs through the use of ---
Inheritance
Encapsulation
Polymorphism
14 CREATION OF JAVA
Java was conceived by James Gosling Patrick Naughton Chris Warth and Mike Sheridan at
Sun Microsystems Inc in 1991 It took 18 months to develop the first working version This
language is initially called ―Oak but was renamed java in 1995 The primary motivation
was the need for a platform-independent (that isarchitecture neutral) language that could be
used to create software to be embedded in various customer electronic devicessuch as
microwave ovens and remote controls
The problem is that compilers are expensive and time consuming to create So Gosling
and others began work on portable platform independent language that is used to
produce code that would run on a variety of CPUs under differing environments This
effort led to the creation of java
Second and ultimately more important factor was emerging that would play a crucial
role the World Wide Web Had the Web not taken shape at about the same time that
java was being implemented java might have remained a useful but obscure language
for programming consumer electronics However with the emergence of the World
Wide Web java was propelled to the forefront of computer language design because the
Web too demanded portable programs
15 ABOUT JAVA
Java technology is both a programming language and a platformIn the Java programming
language all source code is first written in plain text files ending with the java extension
Those source files are then compiled into class files by the javac compiler A class file does
not contain code that is native to your processor it instead contains bytecodes mdash the machine
language of the Java Virtual Machine1 (Java VM) The java launcher tool then runs your
application with an instance of the Java Virtual Machine
Fig 1
The JAVA Platform A platform is the hardware or software environment in which a program
runs The Java platform differs from most other platforms in that its a software-only platform
that runs on top of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
16 FEATURES OF JAVA
Object oriented This means that it takes into consideration real world entities
Cross platform language It means that program can run across several platforms-
Microsoft Windows AppleMacintosh Linux etc The language automatically uses
pointers behind the scenes for complex types and no pointer specific syntax is
requiredAll objects are referenced by pointers--but the language handles them not the
programmer
Simple It was designed to be easy for the professional programmer to learn and use
efficiently
Secure In java Applets provide security feature In order to enable applets to be
downloaded and executed on the client computer safely it was necessary to prevent an
applet from launching such an attack
Portable Same code executes on all computers This feature is provided by java
Object-oriented java provides all OOPS features ie Inheritance Polymorphism
Everything is an object in java The focus therefore is on data and methods that operate
on the objects in the application
Robust The ability to create robust programs was given a high priority in the design of
java
Multithreaded Java supports multithreaded programming which allows you to write
programs that do many things simultaneously
Architecture-neutral Their goal was ―write once run anywhere anytime forever
Interpreted Java creates cross platform programs This code can be executed on any
system that implements the java virtual machine
High performance This cross platform code directly translates native machine code
for very high performance
Distributed It is designed for distributed systems because it handles TCPIP protocols
and also supports Remote method invocation (RMI)
Dynamic It is used to verify and resolved accesses to objects at run time This makes it
possible to dynamically link code in a safe and expedient manner
Platform Independent It refers to the ability of the program to move from one
computer to another without difficulty ie it can run over any operating system Java is
platform independent at source level and binary level Platform Independence at source
level allows user to move the source code from one system to another compile the code
and run it clearly on a systemPlatform Independence at binary level allows user to run
compiled binary file on multiple platform without recompiling the code
17 JAVA ARCHITECTURE
Java is Object-Oriented--that means everything in the language behaves like an object
Javalsquos Architecture comes from four separate but intertwined technologies
The Java Programming Language
The Java class file format
The Java API or Application Programming Interface
The Java Virtual Machine
Source programs are written in the Java Programming Language
All procedural code falls within methods
Programs are compiled into Java class files
Classes run in the Java Virtual Machine
When a Java program runs it is assisted by other classes in the Java the
Application Programming Interface or API
A JVM has an interpreter component that enables communication between java
bytecode and a computers operating system
By using JVM java code can be run on any platform
A JVM reads and executes java statements one at a time
The java compiler is responsible for turning java source code into java bytecode that
can be executed within the java runtime system
The JVM which is a component of runtime system is responsible for interpreting the
bytecode and making the native code out of it
JVM may include JIT ( just in time) compiler in it which converts bytecode into native
code without making use of interpreter
If JIT is not present the bytecode classes will be processed and executed by the runtime
interpreter
The Virtual Machine interprets the bytecode one instruction at a time and
translates it into native machine code
You compile your program once into bytecode but it is interpreted anew every
time it runs
C and C++ are famous for speed
One reason they are fast is because C and C++ donlsquot do things like checking the
bounds of arrays
In C or C++ a program can walk off the edge of an array and invade the
memory space beyond
Hackers love that about C and C++
Another weakness of CC++ that is a favourite among Hackers is the Buffer
Overflow
In this attack the Hacker floods too much data into a buffer and whatever
overflows it is turned loose on the system
Java solves these problems
How Java Combats malicious code
Java checks array boundaries
Java halts Buffer Overflows
Java has Garbage collection to get rid of objects that are no longer used
Javalsquos compiler checks to make sure the code is safe before it run
18A Simple Java Application
The TestGreetingjava Application
Sample Hello World application
public class TestGreeting
public static void main (String [] args)
Greeting hello = new Greeting ()
hellogreet()
The Greetingjava Class
public class Greeting
public void greet()
Systemoutprintln(―hi)
181 Compiling and Running the TestGreeting Program
Compile TestGreetingjava
javac TestGreetingjava
bull The Greetingjava is compiled automatically
bull Run the application by using the following command
java TestGreeting
bull Locate common compile and runtime errors
19 JAVA DATA TYPES
Integers
Table 1
Character
Floating point
Table 2
Boolean
true
false
110 OPERATORS IN JAVA
Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra The following table lists the arithmetic operators
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
DECLARATION
I SHUBHAM SAINI bearing Roll No 11IT055 a bonafide student of The Technological
Institute of Textile amp Sciences would like to declare that the project titled ldquoReport on Core-
Javardquo
A partial fulfillment of BY BACHELOR OF TECHNOLOGY Degree course of MDU
UNIVERSITY is my original work in the year 2013 under the guidance of Mrs Satvika
Assistant Professor of the Department of Information Technology
DATE NAME
ROLL NO 11IT055 SHUBHAM SAINI
PLACE
ACKNOWLEDGEMENT
I would like to express my gratitude to all those who gave me helping hand in completion this
term paper I want to thank my teacher Raj Kumar Sharma for helping me whenever I needed it
the most My friends have also supported me in my work I want to thank them all for their
help support interest and valuable hints
I am extremely thankful to Asstt Prof DrMukesh Sharma HOD Computer Science amp IT The
Technological Institute of Textile amp Sciences Bhiwani for valuable suggestions and
encouragement
Signature of Student
SHUBHAM SAINI
CERTIFICATE
I hereby certify that I have completed the Six weeks Trainingin partial fulfilment of the
requirements for the award of Bachelor of Technology in Information Technology I did my
training in ―Gyan Techno Solution at Rohtak Haryana from 25-06-13 to 30-07-13
The matter presented in this Report has not been submitted by me for the award of any
other degree elsewhere
Signature of Student
SHUBHAM SAINI (11IT055)
Signatures
Examined by (Concerned Faculty)
HOD Department of Computer Engineering amp Information Technology
TABLE OF CONTENTS
1 Introduction
11 What is JAVA
12 Versions of JAVA
13 The Birth Of Modern Programming
14 Creation of Java
15 About Java
16 Features of Java
17 Java Architecture
18 A Simple Java Application
19 Java Data Types
110 Operators in Java
111 Javalsquos Selection Statements
112 Inheritance
113 Exception Handing
114 Multithreading
115 Applets
116 Garbage Collector
117 Constructors
2 Project Work
21 Technology Use
22 Java Platform
23 Introduction to Project
24 General Description
25 Functional Requirements
1 INTRODUCTION TO JAVA
11 What is Java
Java is a computer programming language that is concurrent class-based object-oriented and
specifically designed to have as few implementation dependencies as possible It is intended to
let application developers write once run anywhere (WORA) meaning that code that runs on
one platform does not need to be recompiled to run on another Java applications are
typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM)
regardless of computer architecture
JAVA is related to C++ which is a direct
descendant of C Much of the character of java is
inherited from these two languages From Cjava
derives its syntaxMany of javalsquos object oriented
features were influenced by C++In factseveral of
javalsquos defining characteristics come from or is
responses toits predecessorsMoreover the creation
of java was deeply rooted in the process of
refinement and adaption
12 Versions of Java
JDK Alpha and Beta(1995)
JDK 10(1996)
JDK 11(1997)
J2SE 12(1998)
J2SE 13(2000)
J2SE 14(2002)
J2SE 50(2004)
J2SE(2006)
JAVA SE 7(2011)
13 The Birth of Modern Programming
131 C The creation of C was a direct result of the need for a structured efficienthigh-level
language that could replace assembly code when creating system programs As you probably
know when a computer language is designed trade-offs are often made such as the following
Ease of use versus power
Safety versus efficiency
Rigidity versus extensibility
132 C++ The Next Step
Since C is a successful and useful programming language you might ask why need for
something else existed The answer is Complexity Throughout the history of programmingthe
increasing complexity of programs has driven the need for better ways to manage that
complexity C++ is a response to that need C++ has a features of OOPSOOP is programming
methodology that helps organize complex programs through the use of ---
Inheritance
Encapsulation
Polymorphism
14 CREATION OF JAVA
Java was conceived by James Gosling Patrick Naughton Chris Warth and Mike Sheridan at
Sun Microsystems Inc in 1991 It took 18 months to develop the first working version This
language is initially called ―Oak but was renamed java in 1995 The primary motivation
was the need for a platform-independent (that isarchitecture neutral) language that could be
used to create software to be embedded in various customer electronic devicessuch as
microwave ovens and remote controls
The problem is that compilers are expensive and time consuming to create So Gosling
and others began work on portable platform independent language that is used to
produce code that would run on a variety of CPUs under differing environments This
effort led to the creation of java
Second and ultimately more important factor was emerging that would play a crucial
role the World Wide Web Had the Web not taken shape at about the same time that
java was being implemented java might have remained a useful but obscure language
for programming consumer electronics However with the emergence of the World
Wide Web java was propelled to the forefront of computer language design because the
Web too demanded portable programs
15 ABOUT JAVA
Java technology is both a programming language and a platformIn the Java programming
language all source code is first written in plain text files ending with the java extension
Those source files are then compiled into class files by the javac compiler A class file does
not contain code that is native to your processor it instead contains bytecodes mdash the machine
language of the Java Virtual Machine1 (Java VM) The java launcher tool then runs your
application with an instance of the Java Virtual Machine
Fig 1
The JAVA Platform A platform is the hardware or software environment in which a program
runs The Java platform differs from most other platforms in that its a software-only platform
that runs on top of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
16 FEATURES OF JAVA
Object oriented This means that it takes into consideration real world entities
Cross platform language It means that program can run across several platforms-
Microsoft Windows AppleMacintosh Linux etc The language automatically uses
pointers behind the scenes for complex types and no pointer specific syntax is
requiredAll objects are referenced by pointers--but the language handles them not the
programmer
Simple It was designed to be easy for the professional programmer to learn and use
efficiently
Secure In java Applets provide security feature In order to enable applets to be
downloaded and executed on the client computer safely it was necessary to prevent an
applet from launching such an attack
Portable Same code executes on all computers This feature is provided by java
Object-oriented java provides all OOPS features ie Inheritance Polymorphism
Everything is an object in java The focus therefore is on data and methods that operate
on the objects in the application
Robust The ability to create robust programs was given a high priority in the design of
java
Multithreaded Java supports multithreaded programming which allows you to write
programs that do many things simultaneously
Architecture-neutral Their goal was ―write once run anywhere anytime forever
Interpreted Java creates cross platform programs This code can be executed on any
system that implements the java virtual machine
High performance This cross platform code directly translates native machine code
for very high performance
Distributed It is designed for distributed systems because it handles TCPIP protocols
and also supports Remote method invocation (RMI)
Dynamic It is used to verify and resolved accesses to objects at run time This makes it
possible to dynamically link code in a safe and expedient manner
Platform Independent It refers to the ability of the program to move from one
computer to another without difficulty ie it can run over any operating system Java is
platform independent at source level and binary level Platform Independence at source
level allows user to move the source code from one system to another compile the code
and run it clearly on a systemPlatform Independence at binary level allows user to run
compiled binary file on multiple platform without recompiling the code
17 JAVA ARCHITECTURE
Java is Object-Oriented--that means everything in the language behaves like an object
Javalsquos Architecture comes from four separate but intertwined technologies
The Java Programming Language
The Java class file format
The Java API or Application Programming Interface
The Java Virtual Machine
Source programs are written in the Java Programming Language
All procedural code falls within methods
Programs are compiled into Java class files
Classes run in the Java Virtual Machine
When a Java program runs it is assisted by other classes in the Java the
Application Programming Interface or API
A JVM has an interpreter component that enables communication between java
bytecode and a computers operating system
By using JVM java code can be run on any platform
A JVM reads and executes java statements one at a time
The java compiler is responsible for turning java source code into java bytecode that
can be executed within the java runtime system
The JVM which is a component of runtime system is responsible for interpreting the
bytecode and making the native code out of it
JVM may include JIT ( just in time) compiler in it which converts bytecode into native
code without making use of interpreter
If JIT is not present the bytecode classes will be processed and executed by the runtime
interpreter
The Virtual Machine interprets the bytecode one instruction at a time and
translates it into native machine code
You compile your program once into bytecode but it is interpreted anew every
time it runs
C and C++ are famous for speed
One reason they are fast is because C and C++ donlsquot do things like checking the
bounds of arrays
In C or C++ a program can walk off the edge of an array and invade the
memory space beyond
Hackers love that about C and C++
Another weakness of CC++ that is a favourite among Hackers is the Buffer
Overflow
In this attack the Hacker floods too much data into a buffer and whatever
overflows it is turned loose on the system
Java solves these problems
How Java Combats malicious code
Java checks array boundaries
Java halts Buffer Overflows
Java has Garbage collection to get rid of objects that are no longer used
Javalsquos compiler checks to make sure the code is safe before it run
18A Simple Java Application
The TestGreetingjava Application
Sample Hello World application
public class TestGreeting
public static void main (String [] args)
Greeting hello = new Greeting ()
hellogreet()
The Greetingjava Class
public class Greeting
public void greet()
Systemoutprintln(―hi)
181 Compiling and Running the TestGreeting Program
Compile TestGreetingjava
javac TestGreetingjava
bull The Greetingjava is compiled automatically
bull Run the application by using the following command
java TestGreeting
bull Locate common compile and runtime errors
19 JAVA DATA TYPES
Integers
Table 1
Character
Floating point
Table 2
Boolean
true
false
110 OPERATORS IN JAVA
Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra The following table lists the arithmetic operators
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
ACKNOWLEDGEMENT
I would like to express my gratitude to all those who gave me helping hand in completion this
term paper I want to thank my teacher Raj Kumar Sharma for helping me whenever I needed it
the most My friends have also supported me in my work I want to thank them all for their
help support interest and valuable hints
I am extremely thankful to Asstt Prof DrMukesh Sharma HOD Computer Science amp IT The
Technological Institute of Textile amp Sciences Bhiwani for valuable suggestions and
encouragement
Signature of Student
SHUBHAM SAINI
CERTIFICATE
I hereby certify that I have completed the Six weeks Trainingin partial fulfilment of the
requirements for the award of Bachelor of Technology in Information Technology I did my
training in ―Gyan Techno Solution at Rohtak Haryana from 25-06-13 to 30-07-13
The matter presented in this Report has not been submitted by me for the award of any
other degree elsewhere
Signature of Student
SHUBHAM SAINI (11IT055)
Signatures
Examined by (Concerned Faculty)
HOD Department of Computer Engineering amp Information Technology
TABLE OF CONTENTS
1 Introduction
11 What is JAVA
12 Versions of JAVA
13 The Birth Of Modern Programming
14 Creation of Java
15 About Java
16 Features of Java
17 Java Architecture
18 A Simple Java Application
19 Java Data Types
110 Operators in Java
111 Javalsquos Selection Statements
112 Inheritance
113 Exception Handing
114 Multithreading
115 Applets
116 Garbage Collector
117 Constructors
2 Project Work
21 Technology Use
22 Java Platform
23 Introduction to Project
24 General Description
25 Functional Requirements
1 INTRODUCTION TO JAVA
11 What is Java
Java is a computer programming language that is concurrent class-based object-oriented and
specifically designed to have as few implementation dependencies as possible It is intended to
let application developers write once run anywhere (WORA) meaning that code that runs on
one platform does not need to be recompiled to run on another Java applications are
typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM)
regardless of computer architecture
JAVA is related to C++ which is a direct
descendant of C Much of the character of java is
inherited from these two languages From Cjava
derives its syntaxMany of javalsquos object oriented
features were influenced by C++In factseveral of
javalsquos defining characteristics come from or is
responses toits predecessorsMoreover the creation
of java was deeply rooted in the process of
refinement and adaption
12 Versions of Java
JDK Alpha and Beta(1995)
JDK 10(1996)
JDK 11(1997)
J2SE 12(1998)
J2SE 13(2000)
J2SE 14(2002)
J2SE 50(2004)
J2SE(2006)
JAVA SE 7(2011)
13 The Birth of Modern Programming
131 C The creation of C was a direct result of the need for a structured efficienthigh-level
language that could replace assembly code when creating system programs As you probably
know when a computer language is designed trade-offs are often made such as the following
Ease of use versus power
Safety versus efficiency
Rigidity versus extensibility
132 C++ The Next Step
Since C is a successful and useful programming language you might ask why need for
something else existed The answer is Complexity Throughout the history of programmingthe
increasing complexity of programs has driven the need for better ways to manage that
complexity C++ is a response to that need C++ has a features of OOPSOOP is programming
methodology that helps organize complex programs through the use of ---
Inheritance
Encapsulation
Polymorphism
14 CREATION OF JAVA
Java was conceived by James Gosling Patrick Naughton Chris Warth and Mike Sheridan at
Sun Microsystems Inc in 1991 It took 18 months to develop the first working version This
language is initially called ―Oak but was renamed java in 1995 The primary motivation
was the need for a platform-independent (that isarchitecture neutral) language that could be
used to create software to be embedded in various customer electronic devicessuch as
microwave ovens and remote controls
The problem is that compilers are expensive and time consuming to create So Gosling
and others began work on portable platform independent language that is used to
produce code that would run on a variety of CPUs under differing environments This
effort led to the creation of java
Second and ultimately more important factor was emerging that would play a crucial
role the World Wide Web Had the Web not taken shape at about the same time that
java was being implemented java might have remained a useful but obscure language
for programming consumer electronics However with the emergence of the World
Wide Web java was propelled to the forefront of computer language design because the
Web too demanded portable programs
15 ABOUT JAVA
Java technology is both a programming language and a platformIn the Java programming
language all source code is first written in plain text files ending with the java extension
Those source files are then compiled into class files by the javac compiler A class file does
not contain code that is native to your processor it instead contains bytecodes mdash the machine
language of the Java Virtual Machine1 (Java VM) The java launcher tool then runs your
application with an instance of the Java Virtual Machine
Fig 1
The JAVA Platform A platform is the hardware or software environment in which a program
runs The Java platform differs from most other platforms in that its a software-only platform
that runs on top of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
16 FEATURES OF JAVA
Object oriented This means that it takes into consideration real world entities
Cross platform language It means that program can run across several platforms-
Microsoft Windows AppleMacintosh Linux etc The language automatically uses
pointers behind the scenes for complex types and no pointer specific syntax is
requiredAll objects are referenced by pointers--but the language handles them not the
programmer
Simple It was designed to be easy for the professional programmer to learn and use
efficiently
Secure In java Applets provide security feature In order to enable applets to be
downloaded and executed on the client computer safely it was necessary to prevent an
applet from launching such an attack
Portable Same code executes on all computers This feature is provided by java
Object-oriented java provides all OOPS features ie Inheritance Polymorphism
Everything is an object in java The focus therefore is on data and methods that operate
on the objects in the application
Robust The ability to create robust programs was given a high priority in the design of
java
Multithreaded Java supports multithreaded programming which allows you to write
programs that do many things simultaneously
Architecture-neutral Their goal was ―write once run anywhere anytime forever
Interpreted Java creates cross platform programs This code can be executed on any
system that implements the java virtual machine
High performance This cross platform code directly translates native machine code
for very high performance
Distributed It is designed for distributed systems because it handles TCPIP protocols
and also supports Remote method invocation (RMI)
Dynamic It is used to verify and resolved accesses to objects at run time This makes it
possible to dynamically link code in a safe and expedient manner
Platform Independent It refers to the ability of the program to move from one
computer to another without difficulty ie it can run over any operating system Java is
platform independent at source level and binary level Platform Independence at source
level allows user to move the source code from one system to another compile the code
and run it clearly on a systemPlatform Independence at binary level allows user to run
compiled binary file on multiple platform without recompiling the code
17 JAVA ARCHITECTURE
Java is Object-Oriented--that means everything in the language behaves like an object
Javalsquos Architecture comes from four separate but intertwined technologies
The Java Programming Language
The Java class file format
The Java API or Application Programming Interface
The Java Virtual Machine
Source programs are written in the Java Programming Language
All procedural code falls within methods
Programs are compiled into Java class files
Classes run in the Java Virtual Machine
When a Java program runs it is assisted by other classes in the Java the
Application Programming Interface or API
A JVM has an interpreter component that enables communication between java
bytecode and a computers operating system
By using JVM java code can be run on any platform
A JVM reads and executes java statements one at a time
The java compiler is responsible for turning java source code into java bytecode that
can be executed within the java runtime system
The JVM which is a component of runtime system is responsible for interpreting the
bytecode and making the native code out of it
JVM may include JIT ( just in time) compiler in it which converts bytecode into native
code without making use of interpreter
If JIT is not present the bytecode classes will be processed and executed by the runtime
interpreter
The Virtual Machine interprets the bytecode one instruction at a time and
translates it into native machine code
You compile your program once into bytecode but it is interpreted anew every
time it runs
C and C++ are famous for speed
One reason they are fast is because C and C++ donlsquot do things like checking the
bounds of arrays
In C or C++ a program can walk off the edge of an array and invade the
memory space beyond
Hackers love that about C and C++
Another weakness of CC++ that is a favourite among Hackers is the Buffer
Overflow
In this attack the Hacker floods too much data into a buffer and whatever
overflows it is turned loose on the system
Java solves these problems
How Java Combats malicious code
Java checks array boundaries
Java halts Buffer Overflows
Java has Garbage collection to get rid of objects that are no longer used
Javalsquos compiler checks to make sure the code is safe before it run
18A Simple Java Application
The TestGreetingjava Application
Sample Hello World application
public class TestGreeting
public static void main (String [] args)
Greeting hello = new Greeting ()
hellogreet()
The Greetingjava Class
public class Greeting
public void greet()
Systemoutprintln(―hi)
181 Compiling and Running the TestGreeting Program
Compile TestGreetingjava
javac TestGreetingjava
bull The Greetingjava is compiled automatically
bull Run the application by using the following command
java TestGreeting
bull Locate common compile and runtime errors
19 JAVA DATA TYPES
Integers
Table 1
Character
Floating point
Table 2
Boolean
true
false
110 OPERATORS IN JAVA
Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra The following table lists the arithmetic operators
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
CERTIFICATE
I hereby certify that I have completed the Six weeks Trainingin partial fulfilment of the
requirements for the award of Bachelor of Technology in Information Technology I did my
training in ―Gyan Techno Solution at Rohtak Haryana from 25-06-13 to 30-07-13
The matter presented in this Report has not been submitted by me for the award of any
other degree elsewhere
Signature of Student
SHUBHAM SAINI (11IT055)
Signatures
Examined by (Concerned Faculty)
HOD Department of Computer Engineering amp Information Technology
TABLE OF CONTENTS
1 Introduction
11 What is JAVA
12 Versions of JAVA
13 The Birth Of Modern Programming
14 Creation of Java
15 About Java
16 Features of Java
17 Java Architecture
18 A Simple Java Application
19 Java Data Types
110 Operators in Java
111 Javalsquos Selection Statements
112 Inheritance
113 Exception Handing
114 Multithreading
115 Applets
116 Garbage Collector
117 Constructors
2 Project Work
21 Technology Use
22 Java Platform
23 Introduction to Project
24 General Description
25 Functional Requirements
1 INTRODUCTION TO JAVA
11 What is Java
Java is a computer programming language that is concurrent class-based object-oriented and
specifically designed to have as few implementation dependencies as possible It is intended to
let application developers write once run anywhere (WORA) meaning that code that runs on
one platform does not need to be recompiled to run on another Java applications are
typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM)
regardless of computer architecture
JAVA is related to C++ which is a direct
descendant of C Much of the character of java is
inherited from these two languages From Cjava
derives its syntaxMany of javalsquos object oriented
features were influenced by C++In factseveral of
javalsquos defining characteristics come from or is
responses toits predecessorsMoreover the creation
of java was deeply rooted in the process of
refinement and adaption
12 Versions of Java
JDK Alpha and Beta(1995)
JDK 10(1996)
JDK 11(1997)
J2SE 12(1998)
J2SE 13(2000)
J2SE 14(2002)
J2SE 50(2004)
J2SE(2006)
JAVA SE 7(2011)
13 The Birth of Modern Programming
131 C The creation of C was a direct result of the need for a structured efficienthigh-level
language that could replace assembly code when creating system programs As you probably
know when a computer language is designed trade-offs are often made such as the following
Ease of use versus power
Safety versus efficiency
Rigidity versus extensibility
132 C++ The Next Step
Since C is a successful and useful programming language you might ask why need for
something else existed The answer is Complexity Throughout the history of programmingthe
increasing complexity of programs has driven the need for better ways to manage that
complexity C++ is a response to that need C++ has a features of OOPSOOP is programming
methodology that helps organize complex programs through the use of ---
Inheritance
Encapsulation
Polymorphism
14 CREATION OF JAVA
Java was conceived by James Gosling Patrick Naughton Chris Warth and Mike Sheridan at
Sun Microsystems Inc in 1991 It took 18 months to develop the first working version This
language is initially called ―Oak but was renamed java in 1995 The primary motivation
was the need for a platform-independent (that isarchitecture neutral) language that could be
used to create software to be embedded in various customer electronic devicessuch as
microwave ovens and remote controls
The problem is that compilers are expensive and time consuming to create So Gosling
and others began work on portable platform independent language that is used to
produce code that would run on a variety of CPUs under differing environments This
effort led to the creation of java
Second and ultimately more important factor was emerging that would play a crucial
role the World Wide Web Had the Web not taken shape at about the same time that
java was being implemented java might have remained a useful but obscure language
for programming consumer electronics However with the emergence of the World
Wide Web java was propelled to the forefront of computer language design because the
Web too demanded portable programs
15 ABOUT JAVA
Java technology is both a programming language and a platformIn the Java programming
language all source code is first written in plain text files ending with the java extension
Those source files are then compiled into class files by the javac compiler A class file does
not contain code that is native to your processor it instead contains bytecodes mdash the machine
language of the Java Virtual Machine1 (Java VM) The java launcher tool then runs your
application with an instance of the Java Virtual Machine
Fig 1
The JAVA Platform A platform is the hardware or software environment in which a program
runs The Java platform differs from most other platforms in that its a software-only platform
that runs on top of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
16 FEATURES OF JAVA
Object oriented This means that it takes into consideration real world entities
Cross platform language It means that program can run across several platforms-
Microsoft Windows AppleMacintosh Linux etc The language automatically uses
pointers behind the scenes for complex types and no pointer specific syntax is
requiredAll objects are referenced by pointers--but the language handles them not the
programmer
Simple It was designed to be easy for the professional programmer to learn and use
efficiently
Secure In java Applets provide security feature In order to enable applets to be
downloaded and executed on the client computer safely it was necessary to prevent an
applet from launching such an attack
Portable Same code executes on all computers This feature is provided by java
Object-oriented java provides all OOPS features ie Inheritance Polymorphism
Everything is an object in java The focus therefore is on data and methods that operate
on the objects in the application
Robust The ability to create robust programs was given a high priority in the design of
java
Multithreaded Java supports multithreaded programming which allows you to write
programs that do many things simultaneously
Architecture-neutral Their goal was ―write once run anywhere anytime forever
Interpreted Java creates cross platform programs This code can be executed on any
system that implements the java virtual machine
High performance This cross platform code directly translates native machine code
for very high performance
Distributed It is designed for distributed systems because it handles TCPIP protocols
and also supports Remote method invocation (RMI)
Dynamic It is used to verify and resolved accesses to objects at run time This makes it
possible to dynamically link code in a safe and expedient manner
Platform Independent It refers to the ability of the program to move from one
computer to another without difficulty ie it can run over any operating system Java is
platform independent at source level and binary level Platform Independence at source
level allows user to move the source code from one system to another compile the code
and run it clearly on a systemPlatform Independence at binary level allows user to run
compiled binary file on multiple platform without recompiling the code
17 JAVA ARCHITECTURE
Java is Object-Oriented--that means everything in the language behaves like an object
Javalsquos Architecture comes from four separate but intertwined technologies
The Java Programming Language
The Java class file format
The Java API or Application Programming Interface
The Java Virtual Machine
Source programs are written in the Java Programming Language
All procedural code falls within methods
Programs are compiled into Java class files
Classes run in the Java Virtual Machine
When a Java program runs it is assisted by other classes in the Java the
Application Programming Interface or API
A JVM has an interpreter component that enables communication between java
bytecode and a computers operating system
By using JVM java code can be run on any platform
A JVM reads and executes java statements one at a time
The java compiler is responsible for turning java source code into java bytecode that
can be executed within the java runtime system
The JVM which is a component of runtime system is responsible for interpreting the
bytecode and making the native code out of it
JVM may include JIT ( just in time) compiler in it which converts bytecode into native
code without making use of interpreter
If JIT is not present the bytecode classes will be processed and executed by the runtime
interpreter
The Virtual Machine interprets the bytecode one instruction at a time and
translates it into native machine code
You compile your program once into bytecode but it is interpreted anew every
time it runs
C and C++ are famous for speed
One reason they are fast is because C and C++ donlsquot do things like checking the
bounds of arrays
In C or C++ a program can walk off the edge of an array and invade the
memory space beyond
Hackers love that about C and C++
Another weakness of CC++ that is a favourite among Hackers is the Buffer
Overflow
In this attack the Hacker floods too much data into a buffer and whatever
overflows it is turned loose on the system
Java solves these problems
How Java Combats malicious code
Java checks array boundaries
Java halts Buffer Overflows
Java has Garbage collection to get rid of objects that are no longer used
Javalsquos compiler checks to make sure the code is safe before it run
18A Simple Java Application
The TestGreetingjava Application
Sample Hello World application
public class TestGreeting
public static void main (String [] args)
Greeting hello = new Greeting ()
hellogreet()
The Greetingjava Class
public class Greeting
public void greet()
Systemoutprintln(―hi)
181 Compiling and Running the TestGreeting Program
Compile TestGreetingjava
javac TestGreetingjava
bull The Greetingjava is compiled automatically
bull Run the application by using the following command
java TestGreeting
bull Locate common compile and runtime errors
19 JAVA DATA TYPES
Integers
Table 1
Character
Floating point
Table 2
Boolean
true
false
110 OPERATORS IN JAVA
Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra The following table lists the arithmetic operators
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
TABLE OF CONTENTS
1 Introduction
11 What is JAVA
12 Versions of JAVA
13 The Birth Of Modern Programming
14 Creation of Java
15 About Java
16 Features of Java
17 Java Architecture
18 A Simple Java Application
19 Java Data Types
110 Operators in Java
111 Javalsquos Selection Statements
112 Inheritance
113 Exception Handing
114 Multithreading
115 Applets
116 Garbage Collector
117 Constructors
2 Project Work
21 Technology Use
22 Java Platform
23 Introduction to Project
24 General Description
25 Functional Requirements
1 INTRODUCTION TO JAVA
11 What is Java
Java is a computer programming language that is concurrent class-based object-oriented and
specifically designed to have as few implementation dependencies as possible It is intended to
let application developers write once run anywhere (WORA) meaning that code that runs on
one platform does not need to be recompiled to run on another Java applications are
typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM)
regardless of computer architecture
JAVA is related to C++ which is a direct
descendant of C Much of the character of java is
inherited from these two languages From Cjava
derives its syntaxMany of javalsquos object oriented
features were influenced by C++In factseveral of
javalsquos defining characteristics come from or is
responses toits predecessorsMoreover the creation
of java was deeply rooted in the process of
refinement and adaption
12 Versions of Java
JDK Alpha and Beta(1995)
JDK 10(1996)
JDK 11(1997)
J2SE 12(1998)
J2SE 13(2000)
J2SE 14(2002)
J2SE 50(2004)
J2SE(2006)
JAVA SE 7(2011)
13 The Birth of Modern Programming
131 C The creation of C was a direct result of the need for a structured efficienthigh-level
language that could replace assembly code when creating system programs As you probably
know when a computer language is designed trade-offs are often made such as the following
Ease of use versus power
Safety versus efficiency
Rigidity versus extensibility
132 C++ The Next Step
Since C is a successful and useful programming language you might ask why need for
something else existed The answer is Complexity Throughout the history of programmingthe
increasing complexity of programs has driven the need for better ways to manage that
complexity C++ is a response to that need C++ has a features of OOPSOOP is programming
methodology that helps organize complex programs through the use of ---
Inheritance
Encapsulation
Polymorphism
14 CREATION OF JAVA
Java was conceived by James Gosling Patrick Naughton Chris Warth and Mike Sheridan at
Sun Microsystems Inc in 1991 It took 18 months to develop the first working version This
language is initially called ―Oak but was renamed java in 1995 The primary motivation
was the need for a platform-independent (that isarchitecture neutral) language that could be
used to create software to be embedded in various customer electronic devicessuch as
microwave ovens and remote controls
The problem is that compilers are expensive and time consuming to create So Gosling
and others began work on portable platform independent language that is used to
produce code that would run on a variety of CPUs under differing environments This
effort led to the creation of java
Second and ultimately more important factor was emerging that would play a crucial
role the World Wide Web Had the Web not taken shape at about the same time that
java was being implemented java might have remained a useful but obscure language
for programming consumer electronics However with the emergence of the World
Wide Web java was propelled to the forefront of computer language design because the
Web too demanded portable programs
15 ABOUT JAVA
Java technology is both a programming language and a platformIn the Java programming
language all source code is first written in plain text files ending with the java extension
Those source files are then compiled into class files by the javac compiler A class file does
not contain code that is native to your processor it instead contains bytecodes mdash the machine
language of the Java Virtual Machine1 (Java VM) The java launcher tool then runs your
application with an instance of the Java Virtual Machine
Fig 1
The JAVA Platform A platform is the hardware or software environment in which a program
runs The Java platform differs from most other platforms in that its a software-only platform
that runs on top of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
16 FEATURES OF JAVA
Object oriented This means that it takes into consideration real world entities
Cross platform language It means that program can run across several platforms-
Microsoft Windows AppleMacintosh Linux etc The language automatically uses
pointers behind the scenes for complex types and no pointer specific syntax is
requiredAll objects are referenced by pointers--but the language handles them not the
programmer
Simple It was designed to be easy for the professional programmer to learn and use
efficiently
Secure In java Applets provide security feature In order to enable applets to be
downloaded and executed on the client computer safely it was necessary to prevent an
applet from launching such an attack
Portable Same code executes on all computers This feature is provided by java
Object-oriented java provides all OOPS features ie Inheritance Polymorphism
Everything is an object in java The focus therefore is on data and methods that operate
on the objects in the application
Robust The ability to create robust programs was given a high priority in the design of
java
Multithreaded Java supports multithreaded programming which allows you to write
programs that do many things simultaneously
Architecture-neutral Their goal was ―write once run anywhere anytime forever
Interpreted Java creates cross platform programs This code can be executed on any
system that implements the java virtual machine
High performance This cross platform code directly translates native machine code
for very high performance
Distributed It is designed for distributed systems because it handles TCPIP protocols
and also supports Remote method invocation (RMI)
Dynamic It is used to verify and resolved accesses to objects at run time This makes it
possible to dynamically link code in a safe and expedient manner
Platform Independent It refers to the ability of the program to move from one
computer to another without difficulty ie it can run over any operating system Java is
platform independent at source level and binary level Platform Independence at source
level allows user to move the source code from one system to another compile the code
and run it clearly on a systemPlatform Independence at binary level allows user to run
compiled binary file on multiple platform without recompiling the code
17 JAVA ARCHITECTURE
Java is Object-Oriented--that means everything in the language behaves like an object
Javalsquos Architecture comes from four separate but intertwined technologies
The Java Programming Language
The Java class file format
The Java API or Application Programming Interface
The Java Virtual Machine
Source programs are written in the Java Programming Language
All procedural code falls within methods
Programs are compiled into Java class files
Classes run in the Java Virtual Machine
When a Java program runs it is assisted by other classes in the Java the
Application Programming Interface or API
A JVM has an interpreter component that enables communication between java
bytecode and a computers operating system
By using JVM java code can be run on any platform
A JVM reads and executes java statements one at a time
The java compiler is responsible for turning java source code into java bytecode that
can be executed within the java runtime system
The JVM which is a component of runtime system is responsible for interpreting the
bytecode and making the native code out of it
JVM may include JIT ( just in time) compiler in it which converts bytecode into native
code without making use of interpreter
If JIT is not present the bytecode classes will be processed and executed by the runtime
interpreter
The Virtual Machine interprets the bytecode one instruction at a time and
translates it into native machine code
You compile your program once into bytecode but it is interpreted anew every
time it runs
C and C++ are famous for speed
One reason they are fast is because C and C++ donlsquot do things like checking the
bounds of arrays
In C or C++ a program can walk off the edge of an array and invade the
memory space beyond
Hackers love that about C and C++
Another weakness of CC++ that is a favourite among Hackers is the Buffer
Overflow
In this attack the Hacker floods too much data into a buffer and whatever
overflows it is turned loose on the system
Java solves these problems
How Java Combats malicious code
Java checks array boundaries
Java halts Buffer Overflows
Java has Garbage collection to get rid of objects that are no longer used
Javalsquos compiler checks to make sure the code is safe before it run
18A Simple Java Application
The TestGreetingjava Application
Sample Hello World application
public class TestGreeting
public static void main (String [] args)
Greeting hello = new Greeting ()
hellogreet()
The Greetingjava Class
public class Greeting
public void greet()
Systemoutprintln(―hi)
181 Compiling and Running the TestGreeting Program
Compile TestGreetingjava
javac TestGreetingjava
bull The Greetingjava is compiled automatically
bull Run the application by using the following command
java TestGreeting
bull Locate common compile and runtime errors
19 JAVA DATA TYPES
Integers
Table 1
Character
Floating point
Table 2
Boolean
true
false
110 OPERATORS IN JAVA
Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra The following table lists the arithmetic operators
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
1 INTRODUCTION TO JAVA
11 What is Java
Java is a computer programming language that is concurrent class-based object-oriented and
specifically designed to have as few implementation dependencies as possible It is intended to
let application developers write once run anywhere (WORA) meaning that code that runs on
one platform does not need to be recompiled to run on another Java applications are
typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM)
regardless of computer architecture
JAVA is related to C++ which is a direct
descendant of C Much of the character of java is
inherited from these two languages From Cjava
derives its syntaxMany of javalsquos object oriented
features were influenced by C++In factseveral of
javalsquos defining characteristics come from or is
responses toits predecessorsMoreover the creation
of java was deeply rooted in the process of
refinement and adaption
12 Versions of Java
JDK Alpha and Beta(1995)
JDK 10(1996)
JDK 11(1997)
J2SE 12(1998)
J2SE 13(2000)
J2SE 14(2002)
J2SE 50(2004)
J2SE(2006)
JAVA SE 7(2011)
13 The Birth of Modern Programming
131 C The creation of C was a direct result of the need for a structured efficienthigh-level
language that could replace assembly code when creating system programs As you probably
know when a computer language is designed trade-offs are often made such as the following
Ease of use versus power
Safety versus efficiency
Rigidity versus extensibility
132 C++ The Next Step
Since C is a successful and useful programming language you might ask why need for
something else existed The answer is Complexity Throughout the history of programmingthe
increasing complexity of programs has driven the need for better ways to manage that
complexity C++ is a response to that need C++ has a features of OOPSOOP is programming
methodology that helps organize complex programs through the use of ---
Inheritance
Encapsulation
Polymorphism
14 CREATION OF JAVA
Java was conceived by James Gosling Patrick Naughton Chris Warth and Mike Sheridan at
Sun Microsystems Inc in 1991 It took 18 months to develop the first working version This
language is initially called ―Oak but was renamed java in 1995 The primary motivation
was the need for a platform-independent (that isarchitecture neutral) language that could be
used to create software to be embedded in various customer electronic devicessuch as
microwave ovens and remote controls
The problem is that compilers are expensive and time consuming to create So Gosling
and others began work on portable platform independent language that is used to
produce code that would run on a variety of CPUs under differing environments This
effort led to the creation of java
Second and ultimately more important factor was emerging that would play a crucial
role the World Wide Web Had the Web not taken shape at about the same time that
java was being implemented java might have remained a useful but obscure language
for programming consumer electronics However with the emergence of the World
Wide Web java was propelled to the forefront of computer language design because the
Web too demanded portable programs
15 ABOUT JAVA
Java technology is both a programming language and a platformIn the Java programming
language all source code is first written in plain text files ending with the java extension
Those source files are then compiled into class files by the javac compiler A class file does
not contain code that is native to your processor it instead contains bytecodes mdash the machine
language of the Java Virtual Machine1 (Java VM) The java launcher tool then runs your
application with an instance of the Java Virtual Machine
Fig 1
The JAVA Platform A platform is the hardware or software environment in which a program
runs The Java platform differs from most other platforms in that its a software-only platform
that runs on top of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
16 FEATURES OF JAVA
Object oriented This means that it takes into consideration real world entities
Cross platform language It means that program can run across several platforms-
Microsoft Windows AppleMacintosh Linux etc The language automatically uses
pointers behind the scenes for complex types and no pointer specific syntax is
requiredAll objects are referenced by pointers--but the language handles them not the
programmer
Simple It was designed to be easy for the professional programmer to learn and use
efficiently
Secure In java Applets provide security feature In order to enable applets to be
downloaded and executed on the client computer safely it was necessary to prevent an
applet from launching such an attack
Portable Same code executes on all computers This feature is provided by java
Object-oriented java provides all OOPS features ie Inheritance Polymorphism
Everything is an object in java The focus therefore is on data and methods that operate
on the objects in the application
Robust The ability to create robust programs was given a high priority in the design of
java
Multithreaded Java supports multithreaded programming which allows you to write
programs that do many things simultaneously
Architecture-neutral Their goal was ―write once run anywhere anytime forever
Interpreted Java creates cross platform programs This code can be executed on any
system that implements the java virtual machine
High performance This cross platform code directly translates native machine code
for very high performance
Distributed It is designed for distributed systems because it handles TCPIP protocols
and also supports Remote method invocation (RMI)
Dynamic It is used to verify and resolved accesses to objects at run time This makes it
possible to dynamically link code in a safe and expedient manner
Platform Independent It refers to the ability of the program to move from one
computer to another without difficulty ie it can run over any operating system Java is
platform independent at source level and binary level Platform Independence at source
level allows user to move the source code from one system to another compile the code
and run it clearly on a systemPlatform Independence at binary level allows user to run
compiled binary file on multiple platform without recompiling the code
17 JAVA ARCHITECTURE
Java is Object-Oriented--that means everything in the language behaves like an object
Javalsquos Architecture comes from four separate but intertwined technologies
The Java Programming Language
The Java class file format
The Java API or Application Programming Interface
The Java Virtual Machine
Source programs are written in the Java Programming Language
All procedural code falls within methods
Programs are compiled into Java class files
Classes run in the Java Virtual Machine
When a Java program runs it is assisted by other classes in the Java the
Application Programming Interface or API
A JVM has an interpreter component that enables communication between java
bytecode and a computers operating system
By using JVM java code can be run on any platform
A JVM reads and executes java statements one at a time
The java compiler is responsible for turning java source code into java bytecode that
can be executed within the java runtime system
The JVM which is a component of runtime system is responsible for interpreting the
bytecode and making the native code out of it
JVM may include JIT ( just in time) compiler in it which converts bytecode into native
code without making use of interpreter
If JIT is not present the bytecode classes will be processed and executed by the runtime
interpreter
The Virtual Machine interprets the bytecode one instruction at a time and
translates it into native machine code
You compile your program once into bytecode but it is interpreted anew every
time it runs
C and C++ are famous for speed
One reason they are fast is because C and C++ donlsquot do things like checking the
bounds of arrays
In C or C++ a program can walk off the edge of an array and invade the
memory space beyond
Hackers love that about C and C++
Another weakness of CC++ that is a favourite among Hackers is the Buffer
Overflow
In this attack the Hacker floods too much data into a buffer and whatever
overflows it is turned loose on the system
Java solves these problems
How Java Combats malicious code
Java checks array boundaries
Java halts Buffer Overflows
Java has Garbage collection to get rid of objects that are no longer used
Javalsquos compiler checks to make sure the code is safe before it run
18A Simple Java Application
The TestGreetingjava Application
Sample Hello World application
public class TestGreeting
public static void main (String [] args)
Greeting hello = new Greeting ()
hellogreet()
The Greetingjava Class
public class Greeting
public void greet()
Systemoutprintln(―hi)
181 Compiling and Running the TestGreeting Program
Compile TestGreetingjava
javac TestGreetingjava
bull The Greetingjava is compiled automatically
bull Run the application by using the following command
java TestGreeting
bull Locate common compile and runtime errors
19 JAVA DATA TYPES
Integers
Table 1
Character
Floating point
Table 2
Boolean
true
false
110 OPERATORS IN JAVA
Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra The following table lists the arithmetic operators
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Ease of use versus power
Safety versus efficiency
Rigidity versus extensibility
132 C++ The Next Step
Since C is a successful and useful programming language you might ask why need for
something else existed The answer is Complexity Throughout the history of programmingthe
increasing complexity of programs has driven the need for better ways to manage that
complexity C++ is a response to that need C++ has a features of OOPSOOP is programming
methodology that helps organize complex programs through the use of ---
Inheritance
Encapsulation
Polymorphism
14 CREATION OF JAVA
Java was conceived by James Gosling Patrick Naughton Chris Warth and Mike Sheridan at
Sun Microsystems Inc in 1991 It took 18 months to develop the first working version This
language is initially called ―Oak but was renamed java in 1995 The primary motivation
was the need for a platform-independent (that isarchitecture neutral) language that could be
used to create software to be embedded in various customer electronic devicessuch as
microwave ovens and remote controls
The problem is that compilers are expensive and time consuming to create So Gosling
and others began work on portable platform independent language that is used to
produce code that would run on a variety of CPUs under differing environments This
effort led to the creation of java
Second and ultimately more important factor was emerging that would play a crucial
role the World Wide Web Had the Web not taken shape at about the same time that
java was being implemented java might have remained a useful but obscure language
for programming consumer electronics However with the emergence of the World
Wide Web java was propelled to the forefront of computer language design because the
Web too demanded portable programs
15 ABOUT JAVA
Java technology is both a programming language and a platformIn the Java programming
language all source code is first written in plain text files ending with the java extension
Those source files are then compiled into class files by the javac compiler A class file does
not contain code that is native to your processor it instead contains bytecodes mdash the machine
language of the Java Virtual Machine1 (Java VM) The java launcher tool then runs your
application with an instance of the Java Virtual Machine
Fig 1
The JAVA Platform A platform is the hardware or software environment in which a program
runs The Java platform differs from most other platforms in that its a software-only platform
that runs on top of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
16 FEATURES OF JAVA
Object oriented This means that it takes into consideration real world entities
Cross platform language It means that program can run across several platforms-
Microsoft Windows AppleMacintosh Linux etc The language automatically uses
pointers behind the scenes for complex types and no pointer specific syntax is
requiredAll objects are referenced by pointers--but the language handles them not the
programmer
Simple It was designed to be easy for the professional programmer to learn and use
efficiently
Secure In java Applets provide security feature In order to enable applets to be
downloaded and executed on the client computer safely it was necessary to prevent an
applet from launching such an attack
Portable Same code executes on all computers This feature is provided by java
Object-oriented java provides all OOPS features ie Inheritance Polymorphism
Everything is an object in java The focus therefore is on data and methods that operate
on the objects in the application
Robust The ability to create robust programs was given a high priority in the design of
java
Multithreaded Java supports multithreaded programming which allows you to write
programs that do many things simultaneously
Architecture-neutral Their goal was ―write once run anywhere anytime forever
Interpreted Java creates cross platform programs This code can be executed on any
system that implements the java virtual machine
High performance This cross platform code directly translates native machine code
for very high performance
Distributed It is designed for distributed systems because it handles TCPIP protocols
and also supports Remote method invocation (RMI)
Dynamic It is used to verify and resolved accesses to objects at run time This makes it
possible to dynamically link code in a safe and expedient manner
Platform Independent It refers to the ability of the program to move from one
computer to another without difficulty ie it can run over any operating system Java is
platform independent at source level and binary level Platform Independence at source
level allows user to move the source code from one system to another compile the code
and run it clearly on a systemPlatform Independence at binary level allows user to run
compiled binary file on multiple platform without recompiling the code
17 JAVA ARCHITECTURE
Java is Object-Oriented--that means everything in the language behaves like an object
Javalsquos Architecture comes from four separate but intertwined technologies
The Java Programming Language
The Java class file format
The Java API or Application Programming Interface
The Java Virtual Machine
Source programs are written in the Java Programming Language
All procedural code falls within methods
Programs are compiled into Java class files
Classes run in the Java Virtual Machine
When a Java program runs it is assisted by other classes in the Java the
Application Programming Interface or API
A JVM has an interpreter component that enables communication between java
bytecode and a computers operating system
By using JVM java code can be run on any platform
A JVM reads and executes java statements one at a time
The java compiler is responsible for turning java source code into java bytecode that
can be executed within the java runtime system
The JVM which is a component of runtime system is responsible for interpreting the
bytecode and making the native code out of it
JVM may include JIT ( just in time) compiler in it which converts bytecode into native
code without making use of interpreter
If JIT is not present the bytecode classes will be processed and executed by the runtime
interpreter
The Virtual Machine interprets the bytecode one instruction at a time and
translates it into native machine code
You compile your program once into bytecode but it is interpreted anew every
time it runs
C and C++ are famous for speed
One reason they are fast is because C and C++ donlsquot do things like checking the
bounds of arrays
In C or C++ a program can walk off the edge of an array and invade the
memory space beyond
Hackers love that about C and C++
Another weakness of CC++ that is a favourite among Hackers is the Buffer
Overflow
In this attack the Hacker floods too much data into a buffer and whatever
overflows it is turned loose on the system
Java solves these problems
How Java Combats malicious code
Java checks array boundaries
Java halts Buffer Overflows
Java has Garbage collection to get rid of objects that are no longer used
Javalsquos compiler checks to make sure the code is safe before it run
18A Simple Java Application
The TestGreetingjava Application
Sample Hello World application
public class TestGreeting
public static void main (String [] args)
Greeting hello = new Greeting ()
hellogreet()
The Greetingjava Class
public class Greeting
public void greet()
Systemoutprintln(―hi)
181 Compiling and Running the TestGreeting Program
Compile TestGreetingjava
javac TestGreetingjava
bull The Greetingjava is compiled automatically
bull Run the application by using the following command
java TestGreeting
bull Locate common compile and runtime errors
19 JAVA DATA TYPES
Integers
Table 1
Character
Floating point
Table 2
Boolean
true
false
110 OPERATORS IN JAVA
Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra The following table lists the arithmetic operators
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
15 ABOUT JAVA
Java technology is both a programming language and a platformIn the Java programming
language all source code is first written in plain text files ending with the java extension
Those source files are then compiled into class files by the javac compiler A class file does
not contain code that is native to your processor it instead contains bytecodes mdash the machine
language of the Java Virtual Machine1 (Java VM) The java launcher tool then runs your
application with an instance of the Java Virtual Machine
Fig 1
The JAVA Platform A platform is the hardware or software environment in which a program
runs The Java platform differs from most other platforms in that its a software-only platform
that runs on top of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
16 FEATURES OF JAVA
Object oriented This means that it takes into consideration real world entities
Cross platform language It means that program can run across several platforms-
Microsoft Windows AppleMacintosh Linux etc The language automatically uses
pointers behind the scenes for complex types and no pointer specific syntax is
requiredAll objects are referenced by pointers--but the language handles them not the
programmer
Simple It was designed to be easy for the professional programmer to learn and use
efficiently
Secure In java Applets provide security feature In order to enable applets to be
downloaded and executed on the client computer safely it was necessary to prevent an
applet from launching such an attack
Portable Same code executes on all computers This feature is provided by java
Object-oriented java provides all OOPS features ie Inheritance Polymorphism
Everything is an object in java The focus therefore is on data and methods that operate
on the objects in the application
Robust The ability to create robust programs was given a high priority in the design of
java
Multithreaded Java supports multithreaded programming which allows you to write
programs that do many things simultaneously
Architecture-neutral Their goal was ―write once run anywhere anytime forever
Interpreted Java creates cross platform programs This code can be executed on any
system that implements the java virtual machine
High performance This cross platform code directly translates native machine code
for very high performance
Distributed It is designed for distributed systems because it handles TCPIP protocols
and also supports Remote method invocation (RMI)
Dynamic It is used to verify and resolved accesses to objects at run time This makes it
possible to dynamically link code in a safe and expedient manner
Platform Independent It refers to the ability of the program to move from one
computer to another without difficulty ie it can run over any operating system Java is
platform independent at source level and binary level Platform Independence at source
level allows user to move the source code from one system to another compile the code
and run it clearly on a systemPlatform Independence at binary level allows user to run
compiled binary file on multiple platform without recompiling the code
17 JAVA ARCHITECTURE
Java is Object-Oriented--that means everything in the language behaves like an object
Javalsquos Architecture comes from four separate but intertwined technologies
The Java Programming Language
The Java class file format
The Java API or Application Programming Interface
The Java Virtual Machine
Source programs are written in the Java Programming Language
All procedural code falls within methods
Programs are compiled into Java class files
Classes run in the Java Virtual Machine
When a Java program runs it is assisted by other classes in the Java the
Application Programming Interface or API
A JVM has an interpreter component that enables communication between java
bytecode and a computers operating system
By using JVM java code can be run on any platform
A JVM reads and executes java statements one at a time
The java compiler is responsible for turning java source code into java bytecode that
can be executed within the java runtime system
The JVM which is a component of runtime system is responsible for interpreting the
bytecode and making the native code out of it
JVM may include JIT ( just in time) compiler in it which converts bytecode into native
code without making use of interpreter
If JIT is not present the bytecode classes will be processed and executed by the runtime
interpreter
The Virtual Machine interprets the bytecode one instruction at a time and
translates it into native machine code
You compile your program once into bytecode but it is interpreted anew every
time it runs
C and C++ are famous for speed
One reason they are fast is because C and C++ donlsquot do things like checking the
bounds of arrays
In C or C++ a program can walk off the edge of an array and invade the
memory space beyond
Hackers love that about C and C++
Another weakness of CC++ that is a favourite among Hackers is the Buffer
Overflow
In this attack the Hacker floods too much data into a buffer and whatever
overflows it is turned loose on the system
Java solves these problems
How Java Combats malicious code
Java checks array boundaries
Java halts Buffer Overflows
Java has Garbage collection to get rid of objects that are no longer used
Javalsquos compiler checks to make sure the code is safe before it run
18A Simple Java Application
The TestGreetingjava Application
Sample Hello World application
public class TestGreeting
public static void main (String [] args)
Greeting hello = new Greeting ()
hellogreet()
The Greetingjava Class
public class Greeting
public void greet()
Systemoutprintln(―hi)
181 Compiling and Running the TestGreeting Program
Compile TestGreetingjava
javac TestGreetingjava
bull The Greetingjava is compiled automatically
bull Run the application by using the following command
java TestGreeting
bull Locate common compile and runtime errors
19 JAVA DATA TYPES
Integers
Table 1
Character
Floating point
Table 2
Boolean
true
false
110 OPERATORS IN JAVA
Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra The following table lists the arithmetic operators
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
16 FEATURES OF JAVA
Object oriented This means that it takes into consideration real world entities
Cross platform language It means that program can run across several platforms-
Microsoft Windows AppleMacintosh Linux etc The language automatically uses
pointers behind the scenes for complex types and no pointer specific syntax is
requiredAll objects are referenced by pointers--but the language handles them not the
programmer
Simple It was designed to be easy for the professional programmer to learn and use
efficiently
Secure In java Applets provide security feature In order to enable applets to be
downloaded and executed on the client computer safely it was necessary to prevent an
applet from launching such an attack
Portable Same code executes on all computers This feature is provided by java
Object-oriented java provides all OOPS features ie Inheritance Polymorphism
Everything is an object in java The focus therefore is on data and methods that operate
on the objects in the application
Robust The ability to create robust programs was given a high priority in the design of
java
Multithreaded Java supports multithreaded programming which allows you to write
programs that do many things simultaneously
Architecture-neutral Their goal was ―write once run anywhere anytime forever
Interpreted Java creates cross platform programs This code can be executed on any
system that implements the java virtual machine
High performance This cross platform code directly translates native machine code
for very high performance
Distributed It is designed for distributed systems because it handles TCPIP protocols
and also supports Remote method invocation (RMI)
Dynamic It is used to verify and resolved accesses to objects at run time This makes it
possible to dynamically link code in a safe and expedient manner
Platform Independent It refers to the ability of the program to move from one
computer to another without difficulty ie it can run over any operating system Java is
platform independent at source level and binary level Platform Independence at source
level allows user to move the source code from one system to another compile the code
and run it clearly on a systemPlatform Independence at binary level allows user to run
compiled binary file on multiple platform without recompiling the code
17 JAVA ARCHITECTURE
Java is Object-Oriented--that means everything in the language behaves like an object
Javalsquos Architecture comes from four separate but intertwined technologies
The Java Programming Language
The Java class file format
The Java API or Application Programming Interface
The Java Virtual Machine
Source programs are written in the Java Programming Language
All procedural code falls within methods
Programs are compiled into Java class files
Classes run in the Java Virtual Machine
When a Java program runs it is assisted by other classes in the Java the
Application Programming Interface or API
A JVM has an interpreter component that enables communication between java
bytecode and a computers operating system
By using JVM java code can be run on any platform
A JVM reads and executes java statements one at a time
The java compiler is responsible for turning java source code into java bytecode that
can be executed within the java runtime system
The JVM which is a component of runtime system is responsible for interpreting the
bytecode and making the native code out of it
JVM may include JIT ( just in time) compiler in it which converts bytecode into native
code without making use of interpreter
If JIT is not present the bytecode classes will be processed and executed by the runtime
interpreter
The Virtual Machine interprets the bytecode one instruction at a time and
translates it into native machine code
You compile your program once into bytecode but it is interpreted anew every
time it runs
C and C++ are famous for speed
One reason they are fast is because C and C++ donlsquot do things like checking the
bounds of arrays
In C or C++ a program can walk off the edge of an array and invade the
memory space beyond
Hackers love that about C and C++
Another weakness of CC++ that is a favourite among Hackers is the Buffer
Overflow
In this attack the Hacker floods too much data into a buffer and whatever
overflows it is turned loose on the system
Java solves these problems
How Java Combats malicious code
Java checks array boundaries
Java halts Buffer Overflows
Java has Garbage collection to get rid of objects that are no longer used
Javalsquos compiler checks to make sure the code is safe before it run
18A Simple Java Application
The TestGreetingjava Application
Sample Hello World application
public class TestGreeting
public static void main (String [] args)
Greeting hello = new Greeting ()
hellogreet()
The Greetingjava Class
public class Greeting
public void greet()
Systemoutprintln(―hi)
181 Compiling and Running the TestGreeting Program
Compile TestGreetingjava
javac TestGreetingjava
bull The Greetingjava is compiled automatically
bull Run the application by using the following command
java TestGreeting
bull Locate common compile and runtime errors
19 JAVA DATA TYPES
Integers
Table 1
Character
Floating point
Table 2
Boolean
true
false
110 OPERATORS IN JAVA
Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra The following table lists the arithmetic operators
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Platform Independent It refers to the ability of the program to move from one
computer to another without difficulty ie it can run over any operating system Java is
platform independent at source level and binary level Platform Independence at source
level allows user to move the source code from one system to another compile the code
and run it clearly on a systemPlatform Independence at binary level allows user to run
compiled binary file on multiple platform without recompiling the code
17 JAVA ARCHITECTURE
Java is Object-Oriented--that means everything in the language behaves like an object
Javalsquos Architecture comes from four separate but intertwined technologies
The Java Programming Language
The Java class file format
The Java API or Application Programming Interface
The Java Virtual Machine
Source programs are written in the Java Programming Language
All procedural code falls within methods
Programs are compiled into Java class files
Classes run in the Java Virtual Machine
When a Java program runs it is assisted by other classes in the Java the
Application Programming Interface or API
A JVM has an interpreter component that enables communication between java
bytecode and a computers operating system
By using JVM java code can be run on any platform
A JVM reads and executes java statements one at a time
The java compiler is responsible for turning java source code into java bytecode that
can be executed within the java runtime system
The JVM which is a component of runtime system is responsible for interpreting the
bytecode and making the native code out of it
JVM may include JIT ( just in time) compiler in it which converts bytecode into native
code without making use of interpreter
If JIT is not present the bytecode classes will be processed and executed by the runtime
interpreter
The Virtual Machine interprets the bytecode one instruction at a time and
translates it into native machine code
You compile your program once into bytecode but it is interpreted anew every
time it runs
C and C++ are famous for speed
One reason they are fast is because C and C++ donlsquot do things like checking the
bounds of arrays
In C or C++ a program can walk off the edge of an array and invade the
memory space beyond
Hackers love that about C and C++
Another weakness of CC++ that is a favourite among Hackers is the Buffer
Overflow
In this attack the Hacker floods too much data into a buffer and whatever
overflows it is turned loose on the system
Java solves these problems
How Java Combats malicious code
Java checks array boundaries
Java halts Buffer Overflows
Java has Garbage collection to get rid of objects that are no longer used
Javalsquos compiler checks to make sure the code is safe before it run
18A Simple Java Application
The TestGreetingjava Application
Sample Hello World application
public class TestGreeting
public static void main (String [] args)
Greeting hello = new Greeting ()
hellogreet()
The Greetingjava Class
public class Greeting
public void greet()
Systemoutprintln(―hi)
181 Compiling and Running the TestGreeting Program
Compile TestGreetingjava
javac TestGreetingjava
bull The Greetingjava is compiled automatically
bull Run the application by using the following command
java TestGreeting
bull Locate common compile and runtime errors
19 JAVA DATA TYPES
Integers
Table 1
Character
Floating point
Table 2
Boolean
true
false
110 OPERATORS IN JAVA
Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra The following table lists the arithmetic operators
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
C and C++ are famous for speed
One reason they are fast is because C and C++ donlsquot do things like checking the
bounds of arrays
In C or C++ a program can walk off the edge of an array and invade the
memory space beyond
Hackers love that about C and C++
Another weakness of CC++ that is a favourite among Hackers is the Buffer
Overflow
In this attack the Hacker floods too much data into a buffer and whatever
overflows it is turned loose on the system
Java solves these problems
How Java Combats malicious code
Java checks array boundaries
Java halts Buffer Overflows
Java has Garbage collection to get rid of objects that are no longer used
Javalsquos compiler checks to make sure the code is safe before it run
18A Simple Java Application
The TestGreetingjava Application
Sample Hello World application
public class TestGreeting
public static void main (String [] args)
Greeting hello = new Greeting ()
hellogreet()
The Greetingjava Class
public class Greeting
public void greet()
Systemoutprintln(―hi)
181 Compiling and Running the TestGreeting Program
Compile TestGreetingjava
javac TestGreetingjava
bull The Greetingjava is compiled automatically
bull Run the application by using the following command
java TestGreeting
bull Locate common compile and runtime errors
19 JAVA DATA TYPES
Integers
Table 1
Character
Floating point
Table 2
Boolean
true
false
110 OPERATORS IN JAVA
Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra The following table lists the arithmetic operators
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
181 Compiling and Running the TestGreeting Program
Compile TestGreetingjava
javac TestGreetingjava
bull The Greetingjava is compiled automatically
bull Run the application by using the following command
java TestGreeting
bull Locate common compile and runtime errors
19 JAVA DATA TYPES
Integers
Table 1
Character
Floating point
Table 2
Boolean
true
false
110 OPERATORS IN JAVA
Arithmetic Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used
in algebra The following table lists the arithmetic operators
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Table 3
The Bitwise Operators
Java defines several bitwise operators that can be applied to the integer types long int short
char and byte These operators act upon the individual bits of their operands They are
Summarized in the following table
Table 4
Relational Operators
The relational operators determine the relationship that one operand has to the
otherSpecifically they determine equality and ordering The relational operators are shown
here
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Table 5
Boolean Logical Operators
The Boolean logical operators shown here operate only on Booleanoperands All of the
Binary logical operators combine two Booleanvalues to form a resultant Booleanvalue
Table 6
Table 7
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
111 Javarsquos Selection Statements
if
if else
if else ndash if else ladder
switch
nested switch
Iterations
for
while
do-while
112INHERITENCE
Inheritance is one of the cornerstones of object-oriented programming because it allowsthe
creation of hierarchical classifications Using inheritance you can create a generalclass that
defines traits common to a set of related items This class can then be inheritedby other more
specific classes each adding those things that are unique to it In the terminologyof Java a
class that is inherited is called a superclass The class that does the inheriting is
calledasubclass Therefore a subclass is a specialized version of a superclass It inherits all of
theinstance variables and methods defined by the superclass and add its own unique elements
113 EXCEPTION HANDLING
Exceptions are the run-time errors which can be handled in java applications and do not
result in abnormal termination
Exception handling is a structured mechanism of handling runtime exception in the java
application
Purpose of exception handling is to avoid abnormal termination of the program
114 MULTITHREADEDING
Unlike many other computer languages Java provides built-in support for
multithreadedprogramming
A multithreaded program contains two or more parts that can runconcurrently
Each part of such a program is called a thread and each thread definesa separate
path of execution Thus multithreading is a specialized form of multitasking
You are almost certainly acquainted with multitasking because it is supported
by virtuallyall modern operating systems
There are two distinct types of multitasking processbasedand thread-based
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
115 APPLETS
Appletsare small applications that are accessed on an Internet server transported over the
Internet automatically installed and run as part of a web document After an applet arrives on
the client it has limited access to resources so that it can produce a graphical user interface and
run complex computations without introducing the risk of viruses or breaching data integrity
116 GARBAGE COLLECTOR
The JVM automatically re-collects the memory which is not referred to by other objects The
java garbage collector checks all object references and find the objects which can be
automatically released
While the garbage collector releases the programmer from the need to explicitly manage
memory the programmer still need to ensure that he does not keep unneeded object references
otherwise the garbage collector cannot release the associated memory Keeping unneeded
object references are typically called memory leaks
117 CONSTRUCTORS
In object-oriented programming a constructor (sometimes shortened to ctor) in a class is a
special type of subroutine called to create an object It prepares the new object for use often
accepting arguments that the constructor uses to set member variables required
A constructor resembles an instance method but it differs from a method in that it has no
explicit return type it is not implicitly inherited and it usually has different rules for scope
modifiers Constructors often have the same name as the declaring class They have the task
of initializing the objects data members and of establishing the invariant of the class failing if
the invariant is invalid A properly written constructor leaves the resulting object in
a valid state Immutable objects must be initialized in a constructor
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
2 PROJECT
21 TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is based Today
we are living in a world where technologies related to information technology are evolving
every day new technologies are taking an edge over the older ones Every new technology
provides some new benefits but only small part of them remains in the competitive world
JAVA is the latest technology which is in use nowadays and has proved to be the most reliable
development framework
22 JAVA Platform
A platform is the hardware or software environment in which a program runs The Java
platform differs from most other platforms in that its a software-only platform that runs on top
of other hardware-based platforms
The Java platform has two components
The Java Virtual Machine
The Java Application Programming Interface (API)
The general-purpose high-level Java programming language is a powerful software platform
Every full implementation of the Java platform gives you the following features
Development Tools The development tools provide everything youll need for
compiling running monitoring debugging and documenting your applications As a
new developer the main tools youll be using are the javac compiler the java launcher
and the javadoc documentation tool
Application Programming Interface (API) The API provides the core functionality
of the Java programming language It offers a wide array of useful classes ready for use
in your own applications It spans everything from basic objects to networking and
security
User Interface Toolkits The Swing and Java 2D toolkits make it possible to create
sophisticated Graphical User Interfaces (GUIs)
Class Thread A thread is a thread of execution in a program The Java Virtual
Machine allows an application to have multiple threads of execution running
concurrently Every thread has a priority Threads with higher priority are executed in
preference to threads with lower priority
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
STUDENT MANAGEMENT SYSTEM
1 A Student Management System with the following functions
Add class ndash Set metadata for a new class
Add Record ndash To add student record
Show Record ndash To view Records
Modify Record ndash To modify student records
2 Used Button for the numbers and functions
3 Used TextField for the displaying
4 Used JFrame for the component
5 Created a class to respond to the events caused by numbers functions exit
6 Used FlowLayout to layout various components in the Calculator Frame
A FlowLayout out a container arranging and resizing its components to fit in according to
there occurrences for addition in frame
7 import statements are used to import different packages ad classes
8comments are used to explain the functions of statements
9jdk 17 kit is used
10 The calculator will respond to both mouse and keyboard events
23 Introduction to Project
Calculator is basically designed for providing an effective and easy interface for the
calculation
It is designed here at a very basic level and in such a way it has scope for expansion as
per the requirements
Its simplicity does not affect its security at all
Calculaor has been built in JAVA which itself is a platform independent language
which further adds to Project being universal
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Scope and Objective
The main objective of the application is to have quick calculations
The project can be used in calculating at various levels
Software used
JDK(Java Development Kit) 17
JRE(Java Run Time Environment) 60
Command Prompt
24 General Description
Product Description
This software is aimed toward evey person who needs the calculation or teacher and the
students of the organizationcomputations regarding the results of the students according to
their internal exams It should be user-friendly quick to learnlsquo and reliable software for the
above purpose
This is intended to be a stand-alone product and should not depend on the availability of other
software but the back-end database file already provided with the package It should run on
both UNIX and Windows based platform
The product aims at the following objectives
Smooth flow of data without any hurdles
Flexibility in the system according to the changing environment
Accuracy timeliness and comprehensiveness of the system output
Stability and operability by people of average intelligence
Enhancement in the completion of work within the constraints of time
Product Functions
Checking the correct input
Generating the result
Displaying the print panel
Calculating the result according to the input
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
25 Functional Requirement
Input
Initially the interface takes as input as numbers
Operation to be performed is selected
Processing
The inputs are processed and the operation is applied
Output
Result gets displayed
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Java Application to create a Student Management System
CODING
Login Window
import javaxswing
import javaawt
import javaawtevent
import javasql
public class Login extends Central implements ActionListener KeyListener
private static Login ob = null
private JFrame frame = new JFrame(Application)
private JTextField user
private JPasswordField pass
private JLabel us = new JLabel(Username)
private JLabel pa = new JLabel(Password)
private JButton submit = new JButton(Submit)
private JLabel log = new JLabel( Login Credentials )
private JButton exit = new JButton(Exit)
int flag=0
Login()
user = new JTextField(20)
pass = new JPasswordField(20)
framesetLayout(new FlowLayout())
framegetContentPane()setBackground(new Color(200222255))
framesetVisible(true)
framesetLocation(533250)
frameadd(log)
frameadd(us) frameadd(user)
frameadd(pa) frameadd(pass)
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
frameadd(submit)
frameadd(exit)
framesetSize(307239)
usergrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
submitaddActionListener(this) submitaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
useraddKeyListener(this) submitsetEnabled(false)
passaddKeyListener(this)
public static Login getLogin()
if(ob==null)
ob = new Login()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
new Login()
public void submit()
if(usergetText()equals())
JOptionPaneshowMessageDialog(nullUsername field is mandatory)
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
return
if(StringvalueOf(passgetPassword())equals())
JOptionPaneshowMessageDialog(nullPassword field is mandatory)
return
try
ClassforName(oraclejdbcdriverOracleDriver)
Connection conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
Statement stmt = conncreateStatement()
ResultSet resultSet = null
ResultSetMetaData metaData = null
String s1 = usergetText()
String s2 = StringvalueOf(passgetPassword())
String str = select from Auth where NAME=+s1+ and
Pass=+s2+
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
framedispose()
First first = new First()
initFirst()
else
JOptionPaneshowMessageDialog(nullIncorrect Username or
Password Please try again)
usersetText()
passsetText()
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
usergrabFocus()
catch(ClassNotFoundException ee)
catch(SQLException eee)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == submit)
submit()
else if( btn == exit)
Systemexit(0)
public void keyPressed(KeyEvent e)
if(egetKeyCode() == 10)
Object focus = (Object) framegetFocusOwner()
if(focus instanceof JTextField)
submitgrabFocus()
submit()
else if(focus instanceof JButton)
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
if(submitisFocusOwner() == true)
submit()
else if( exitisFocusOwner() == true)
Systemexit(0)
else
if(egetSource() instanceof JPasswordField)
if((usergetText()equals()))
submitsetEnabled(true)
else if(egetSource() instanceof JTextField)
if((StringvalueOf(passgetPassword())equals()))
submitsetEnabled(true)
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
public void keyTyped(KeyEvent e)
Main Window
import javaxswing
import javaawt
import javaawtevent
public class Permanent implements ActionListener KeyListener
private JFrame frame = new JFrame()
private JButton addClass = new JButton(Add Class)
private JButton addRecord = new JButton(Add Record)
private JButton showRecord = new JButton(Show Record)
private JButton exit = new JButton(Exit)
private ImageIcon img = new
ImageIcon(CUsersShubhamDesktopProjectteacherjpg)
private static Permanent ob = null
Permanent()
framesetLocation(400150)
framesetSize(355475)
framesetLayout(new FlowLayout())
frameadd(new JLabel(img))
frameadd(addClass)
frameadd(addRecord)
frameadd(showRecord)
frameadd(exit)
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
addClassaddActionListener(this) addClassaddKeyListener(this)
addRecordaddActionListener(this) addRecordaddKeyListener(this)
showRecordaddActionListener(this) showRecordaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
public static Permanent getPermanent()
if(ob==null)
ob = new Permanent()
return ob
public JFrame getFrame()
return frame
public static void main(String args[])
PermanentgetPermanent()getFrame()setVisible(true)
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn == addClass)
FirstgetFirst()getFrame()setVisible(true)
else if(btn == addRecord)
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(btn == showRecord)
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if (btn == exit)
Systemexit(0)
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(addClassisFocusOwner())
FirstgetFirst()getFrame()setVisible(true)
else if(addRecordisFocusOwner())
AddRecordgetAddRecord()getFrame()setVisible(true)
else if(showRecordisFocusOwner())
RecordSearchgetRecordSearch()getFrame()setVisible(true)
else if(exitisFocusOwner())
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Systemexit(0)
public void keyReleased(KeyEvent e)
Add Record(Window 1)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class AddRecord implements ActionListenerKeyListenerItemListener
private JFrame frame = new JFrame(Add Record)
private static AddRecord ob = null
private JComboBox jcb1 = new JComboBox()
private JComboBox jcb2 = new JComboBox()
private JComboBox jcb3 = new JComboBox()
private Connection conn
private Statement stmt
private JButton cont = new JButton(Continue)
AddRecord()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLocation(533250)
framesetLayout(new FlowLayout())
framesetSize(400400)
getSubjects()
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Subject ))
frameadd(jcb1)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Branch))
frameadd(jcb2)
frameadd(new JLabel(
))
frameadd(new JLabel(EnterSelect Semester))
frameadd(jcb3)
frameadd(new JLabel(
))
frameadd(cont)
framesetDefaultCloseOperation(JFrameHIDE_ON_CLOSE)
contaddActionListener(this) contaddKeyListener(this)
jcb1addItemListener(this) jcb2addItemListener(this)
jcb1grabFocus()
public void getSubjects()
try
ResultSet resultSet = null
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
String str = select distinct subject from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb1addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct branch from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
str = select distinct semester from subject
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcb3addItem((StringvalueOf(resultSetgetObject(1)))trim())
func()
framerepaint()
framevalidate()
catch(Exception e)eprintStackTrace()
public static AddRecord getAddRecord()
if(ob==null)
ob = new AddRecord()
return ob
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
public String getSubject()
return StringvalueOf(jcb1getSelectedItem())
public String getBranch()
return StringvalueOf(jcb2getSelectedItem())
public String getSemester()
return StringvalueOf(jcb3getSelectedItem())
public static void main(String args[])
AddRecordgetAddRecord()getFrame()setVisible(true)
public JFrame getFrame()
return frame
public void submit()
framesetVisible(false)
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void itemStateChanged(ItemEvent e)
JComboBox j = (JComboBox)egetSource()
if( j == jcb1)
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
func()
public void func()
try
int flag=0
ResultSet resultSet = null
String s1 = (StringvalueOf(jcb1getSelectedItem())toUpperCase())
String str =select distinct branchsemester from subject where
subject=+s1+
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
if(flag==0)
jcb2removeAllItems()
jcb3removeAllItems()
flag=1
jcb2addItem((StringvalueOf(resultSetgetObject(1)))trim())
jcb3addItem((StringvalueOf(resultSetgetObject(2)))trim())
catch(Exception ee)eeprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == cont)
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
submit()
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(contisFocusOwner())
submit()
public void keyReleased(KeyEvent e)
Record Entry (Window 2)
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordEntry implements ActionListener KeyListener
int f = 0
private static RecordEntry ob = null
private JFrame frame = new JFrame(Enter Student Record)
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
private JTextField tf[] = new JTextField[11]
private int counter = 0
private JButton save = new JButton(Save)
private JButton cancel = new JButton(Cancel)
private JButton reset = new JButton(Reset)
private Connection conn
private Statement stmt
public static RecordEntry getRecordEntry()
if(ob==null)
ob= new RecordEntry()
return ob
public Frame getFrame()
return frame
public RecordEntry()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetLayout(new FlowLayout())
framesetSize(650400)
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
framesetLocation(533250)
frameadd(new JLabel( Student Record Entry Form
))
frameadd(new JLabel(
))
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Subject))
getCombo()
frameadd(tf[2] = new JTextField(20))
tf[2]setText(AddRecordgetAddRecord()getSubject())
frameadd(lb[3] = new JLabel( Branch))
frameadd(tf[3] = new JTextField(20))
tf[3]setText(AddRecordgetAddRecord()getBranch())
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Semester))
frameadd(tf[6] = new JTextField(20))
tf[6]setText(AddRecordgetAddRecord()getSemester())
frameadd(new JLabel( ))
frameadd(new JLabel( ))
tf[2]setEditable(false)
tf[3]setEditable(false)
tf[6]setEditable(false)
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
addMarks()
tf[3]= new JTextField(20)
tf[2]= new JTextField(20)
tf[6]= new JTextField(20)
saveaddActionListener(this)
canceladdActionListener(this)
resetaddActionListener(this)
saveaddKeyListener(this) canceladdKeyListener(this)
resetaddKeyListener(this)
tf[0]grabFocus()
public void addMarks()
for(int i=0 i lt getCount() i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
frameadd(new JLabel( ))
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
frameadd(save) frameadd(cancel) frameadd(reset)
public int getCount()
String s1 = AddRecordgetAddRecord()getSubject()
String s2 = AddRecordgetAddRecord()getBranch()
String str = select np from subject where subject=+s1+ and
branch=+s2+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public static void main(String args[])
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
RecordEntrygetRecordEntry()getFrame()setVisible(true)
public void submit()
try
int flag=0
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
ResultSet resultSet = null
String str = create table +s1+ (name char(30)roll char(30)branch char(30)
sem char(30)subject char(30)np int m1 intm2 intm3 intm4 intatten intcp int)
stmtexecuteUpdate(str)
handle()
catch(Exception e)
handle()
public void handle()
try
String s1 =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))replaceAll( )
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
String getBranch =
(StringvalueOf(AddRecordgetAddRecord()getBranch()))
String getSemester =
(StringvalueOf(AddRecordgetAddRecord()getSemester()))
String getSubject =
(StringvalueOf(AddRecordgetAddRecord()getSubject()))
if(resultSetnext())
String exe = insert into +s1+
values(+getName()++getRoll()++getBranch++getSemester++getSubject++g
etCount()+000000)
stmtexecuteUpdate(exe)
Systemoutprintln(arrlength)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
public void actionPerformed(ActionEvent e)
JButton btn = (JButton) egetSource()
if(btn == save)
submit()
else if(btn == cancel)
framedispose()
else if(btn == reset)
for(int i=0 ilt7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(saveisFocusOwner())
submit()
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
else if(cancelisFocusOwner())
framedispose()
else if(resetisFocusOwner())
for(int i=0 ilt 7i++)
tf[i]setText()
for(int i=0iltgetCount()i++)
tf[i+7]setText()
public String getName()
return tf[0]getText()
public String getRoll()
return (tf[1]getText()toUpperCase())
public String getBranch()
return tf[3]getText()
public String getSem()
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
return tf[6]getText()
public int getAtten()
return IntegerparseInt(tf[4]getText())
public int getClassPerf()
return IntegerparseInt(tf[5]getText())
public String getSubject()
return tf[2]getText()
public int[] getMarks()
int arr[] = new int[getCount()]
for(int i =0iltarrlengthi++)
arr[i] = IntegerparseInt(tf[7+i]getText())
return arr
public void keyReleased(KeyEvent e)
public void keyTyped(KeyEvent e)
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
RecordSearch
import javaxswing
import javaawt
import javaawtevent
import javasql
public class RecordSearch implements KeyListener ActionListener
private JFrame frame = new JFrame(Search Student Record)
private static RecordSearch ob = null
private JLabel lb[] = new JLabel[11]
private JTextField tf[] = new JTextField[11]
private JComboBox jcb = new JComboBox()
private JTextField tt = new JTextField(20)
private Connection conn
private Statement stmt
String s1branchre
private int flag=0
int f=0
private JButton modify = new JButton(Modify)
private JButton exit = new JButton(Exit)
public RecordSearch()
try
ResultSet resultSet = null
ClassforName(oraclejdbcdriverOracleDriver)
conn =
DriverManagergetConnection(jdbcoraclethinlocalhost1521xesystembackroom)
stmt = conncreateStatement()
catch(Exception e)eprintStackTrace()
framesetVisible(true)
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
framesetLocation(533250)
framesetSize(640430)
forJCB()
framesetLayout(new FlowLayout())
frameadd(new JLabel( Record Search
Form ))
frameadd(new JLabel(
))
frameadd(jcb)
frameadd(new JLabel(Enter Roll Number Name of Student))
frameadd(tt)
frameadd(new JLabel( ))
jcbgrabFocus()
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE)
ttaddKeyListener(this)
public void forJCB()
String str =select distinct subject from subject
ResultSet resultSet = null
try
resultSet = stmtexecuteQuery(str)
while(resultSetnext())
jcbaddItem((StringvalueOf(resultSetgetObject(1)))trim())
catch(Exception e)eprintStackTrace()
public void reBuild()
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
frameadd(lb[0] = new JLabel(Name ))
frameadd(tf[0] = new JTextField(20))
frameadd(new JLabel( ))
frameadd(lb[1] = new JLabel(Roll Number))
frameadd(tf[1] = new JTextField(20))
frameadd(lb[2] = new JLabel(Branch))
frameadd(tf[2] = new JTextField(20))
frameadd(lb[3] = new JLabel( Semester))
frameadd(tf[3] = new JTextField(20))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[6] = new JLabel(Subject))
frameadd(tf[6] = new JTextField(20))
frameadd(new JLabel( ))
lb[4] = new JLabel(Attendance)
tf[4] = new JTextField(20)
lb[5] = new JLabel(ClassPerformance)
tf[5] = new JTextField(20)
for(int i=0 i lt 4 i++)
frameadd(lb[i+7] = new JLabel(Marks Periodical + (i+1)))
frameadd(tf[i+7] = new JTextField(20))
if(i=3)
frameadd(new JLabel(
))
else
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
frameadd(new JLabel( ))
frameadd(new JLabel(
))
frameadd(new JLabel( ))
frameadd(lb[4])
frameadd(tf[4])
frameadd(new JLabel( ))
frameadd(lb[5])
frameadd(tf[5])
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
frameadd(new JLabel( ))
frameadd(modify)
frameadd(exit)
modifyaddActionListener(this) modifyaddKeyListener(this)
exitaddActionListener(this) exitaddKeyListener(this)
framerepaint()
framevalidate()
sub()
public int getCount()
String s1 = (getSubject()toUpperCase())
String str = select np from subject where subject=+s1+
int res = 0
try
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
ResultSet resultSet = null
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
res = IntegerparseInt(StringvalueOf(resultSetgetObject(1)))
catch(Exception e)eprintStackTrace()
return res
public void sub()
String sub = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
ResultSet resultSet = null
String str = select from +sub+ where roll=+getRoll()+
try
resultSet = stmtexecuteQuery(str)
if(resultSetnext())
String sr[] = new String[12]
for(int i=0ilt12i++)
sr[i]=(StringvalueOf(resultSetgetObject(i+1)))trim()
for(int i=0ilt4i++)
tf[i]setText(sr[i])
tf[4]setText(sr[10])
tf[5]setText(sr[11])
tf[6]setText(sr[4])
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
int i=0
for(i=0iltgetCount()i++)
tf[i+7]setText(sr[i+6])
for(ilt4i++)
tf[i+7]setText(-)
catch(Exception ee)eeprintStackTrace()
public void keyPressed(KeyEvent e)
if(egetKeyCode()==10)
if(ttisFocusOwner() ampamp ttgetText()=)
if(f==0)
f=1
reBuild()
else
sub()
else if(exitisFocusOwner())
framesetVisible(false)
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
else if(modifyisFocusOwner())
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
public void submit()
try
String s1 = (StringvalueOf(jcbgetSelectedItem())replaceAll( ))
int arr[] = getMarks()
String str = select from +s1+
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
ResultSet resultSet = stmtexecuteQuery(str)
if( resultSetnext())
str = select from +s1+ where roll=+getRoll()+
resultSet = stmtexecuteQuery(str)
if( resultSetnext())
String exe = update +s1+ set
name=+getName()+roll=+getRoll()+branch=+getBranch()+sem=+getSemester()+
subject=+getSubject()+np=+getCount()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
for(int i=1 ilt=arrlength i++)
String ex1 = update +s1+ set m+i+=+arr[i-
1]+ where roll=+getRoll()+
stmtexecuteUpdate(ex1)
exe = update +s1+ set atten=+getAtten()+
cp=+getClassPerf()+ where roll=+getRoll()+
stmtexecuteUpdate(exe)
else
JOptionPaneshowMessageDialog(nullRoll No Already
exists)
catch(Exception e)eprintStackTrace()
public void actionPerformed(ActionEvent e)
JButton btn = (JButton)egetSource()
if(btn==exit)
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
framesetVisible(false)
else if(btn== modify)
if(modifygetText()equals(Modify))
for(int i=0 ilt11 i++)
tf[i]setEditable(true)
tf[0]grabFocus()
modifysetText(Save)
else if(modifygetText()equals(Save))
submit()
for(int i=0 ilt11 i++)
tf[i]setEditable(false)
modifysetText(Modify)
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
COMPILATION
Fig 2
RUNNING
Fig 3
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
OUTPUTS
Fig 4
Fig 5
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Fig 6
Add Class STEP 1
Fig 7
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
STEP 2
Fig 8
STEP 3
Fig 9
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Step 4
Fig 10
Record Entry
Fig 11
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Fig 12
Fig 13
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Record Search
Fig 14
Fig 15
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Fig 16
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM
Refrences
THE COMPLETE REFERENCE JAVA SEVENTH EDITION
BY-HERBERT SCHILDT
JAVA HOW TO PROGRAM
BY-DEITEL AND DEITEL
Websites
WWW W3SCHOOL COM
WWWJAVATUTORIALCOM