0% found this document useful (0 votes)
69 views341 pages

Study Notion

Uploaded by

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

Study Notion

Uploaded by

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

“<Study Notion>”

Project Report

Submitted in partial fulfillment of the requirement for the award of

Degree of

Bachelor of Computer Applications

Submitted to

<444> - <SSSPTM>

Submitted By Under Joint Guidance of


<Aniket chauarsiya> Prof. Ravi Kumar Soni &
Registration No.<your reg. no> Prof. Niraj Kumar Singh
BCA-3RD Year [Asst. Professor]
Session-2021-2024 Computer Science &
Information Technology
<College Name>
Department of Computer Science & Information Technology
Session 2021-24

DATE:…18/04/2024……………

CERTIFICATE
This is to certify that the work embodies in this project entitled, “<Study

Notion”, being submitted by <Aniket Chaurasiya> (< 202144400045 >)


in partial fulfillment of the requirement for the award of “Bachelor of
Computer Applications” to PATLIPUTRA UNIVERSITY, PATNA during the
academic year 2021-24 is a record of Bonafide piece of work, carried out by
him/her under our/my supervision and guidance in the “Department of
Computer Science & information Technology”, <SSSPTM>.

Prof. Neeraj Agrawal Er. Amit Kumar Shukla Prof. Ravi Soni
Director Head of Department-IT Assistant Professor-IT

Page1|
<SSSPTM>

Department of Computer Science & Information Technology

Session 2021-24

Date:

APPROVAL CERTIFICATE
The project report entitled “ED platform study notin”, being submitted by
<Aniket Chaursiya> (< 202144400045 >) has been examined by us and is
hereby approved for the award of degree “Bachelor of Computer
Applications”, for which it has been submitted. It is understood that by
this approval the undersigned do not necessarily endorse or approve any
statement made, the opinion expressed or conclusion drawn therein, but
approve the project only for the purpose for which it has been submitted.

(Internal Examiner) (External Examiner)

Date: Date:

Page2|
<SSSPTM>

Department of Computer Science & Information Technology

Session 2021-24

Date:

DECLARATION

I, <Aniket chaursiya> hereby declare that the work, which is being

presented in the project report entitled “<study notion>”, partial

fulfillment of the requirements for the award of degree of “Bachelor of

Computer Applications” submitted in the department of Computer

Science & Information Technology (<SSSptm>) is an authentic record of

my own work carried under the joint guidance of Prof. Niraj Kumar

Singh Sir and Prof. Ravi Kumar Soni Sir. I have not submitted the

matter embodied in this report for the award of any other degree.

<Aniket chaursiya>

Registration No : <

202144400045 > BCA 3RD


Year

Session-2021-2024

Page3|
ACKNOWLEDGEMENT

“A journey is easier when you travel together. Interdependence is certainly more valuable than
independence.”

I would like to thanks, Prof. Niraj Kumar Singh Sir and Prof. Ravi Soni Sir, for providing
regular guidance and insight into my project work. I also thank them for all advice he has given me in the
past year, and for always having time for me, whenever I needed.

I give special thanks to Er. Amit Kumar Shukla Sir, Prof. Anjesh Sir and Prof. Raju Upadhyay
Sir for always being willing to help find solutions to any problems I had with my work.

“The completion of any project depends upon the cooperation, coordination, and
combined efforts of several resources of knowledge, inspiration, and energy”.

I also extend my deepest gratitude to Director, CIMAGE GROUP OF INSTITUITIONS, PATNA,


Prof. Neeraj Agrawal Sir, Dean CIMAGE GROUP OF INSTITUITIONS, PATNA, Prof. Neeraj Kumar
Sir and Centre Head Mrs. Megha Agrawal Mam for providing all the necessary facilities and true
encouraging environment to bring out the best in my endeavors.

I express my gratitude and thanks to all the staff members of Computer Science departments for
their sincere cooperation in furnishing relevant information to complete this Project well in time
successfully.

I extend a special word to my friends, who have been a constant source of inspiration throughout
my project work.

Lastly but not least I must express my cordial thank to my parent and family members who gave
me the moral support without that it is impossible to complete my project work. With this note, I thank
everyone for the support.

(<Aniket Chaurasiya>)

Registration No : < 202144400045 >


BCA 3rd Year

Session-2021-2024

Page4|
CONTENTS
REPORT...................................................................................................……………………………………………...

INTRODUCTION........................................................................................................................................8

OBJECTIVE.............................................................................................................................................. 9

PROJECT CATEGORY JAVA.................................................................................................................10

ADVANTAGES OF JAVA........................................................................................................................11

TOOLS/PLATFORM required...................................................................................................................13

HARDWARE & SOFTWARE REQUIREMENTS...................................................................................13

PROBLEM DEFINITION...........................................................................................................................14

REQUIREMENT SPECIFICATIONS......................................................................................................14

PROJECT PLANNING & SCHEDULING..................................................................................................14

GANTT CHART......................................................................................................................................16

PERT CHART..........................................................................................................................................18

SYSTEM ANALYSIS......................................................................................................................................1

IDENTIFICATION OF NEED..................................................................................................................1

FEASIBILITY STUDY...............................................................................................................................6

TECHNICAL FEASIBILITY:.................................................................................................................7

ECONOMICAL FEASIBILITY:.............................................................................................................7

OPERATIONAL FEASIBILITY:............................................................................................................8

ANALYSIS................................................................................................................................................... 10

DFD..........................................................................................................................................................10

MODULE DESCRIPTION..........................................................................................................................16

DATA STRUCTURE Snap shot..................................................................................................................17

LIST OF REPORTS.....................................................................................................................................22

SCOPE AND FUTURE ENHANCEMENT................................................................................................23

IMPLEMENTATION METHODOLOGY..............................................................................................23

Page5|
TESTING.....................................................................................................................................................25

LIMITATIONSANDFURTHER ENHANCEMENTS................................................................................28

SECURITY MECHANISM.........................................................................................................................29

SNAPSHOTS.............................................................................................................................................. 30

Page6|
SAMPLE PROJECT

Page7|
INTRODUCTION
The “SCHOOL MANAGEMENT SYSTEM” has been design with the help of two

powerful programming languages “JAVA” and “MySQL”. The “JAVA” being in the

foreground and the “MySQL” in the background respectively.

The foreground language is favorite today, due to his interactive user interface and

supporting powerful tool for development of interactive software.

The background language is favorite many of the programmers because it offers the

much wanted structured query facility. The MySQL provides high security, as the

database is stored in the logical area called “DB Engine”. As “DB Engine” is created

in the virtual memory and end user cannot access that directly it.

With these thoughts the “SCHOOL MANAGEMENT SYSTEM” has been

developed. The “JAVA” gives the interactive look and “MySQL” gives high security.

The “JAVAHAR NAVODAYA VIDYALAYA” is a big school of our country, it should

have high security. So the “SCHOOL MANAGEMENT SYSTEM” has been developed

after brainstorming the needs and requirements of the “JAVAHAR NAVODAYA

VIDYALAYA”.

Page8|
OBJECTIVE

The motive of the project entitled “School Automation System” is to


maintain all the record and activities taken place in the administrative
department of the school.

The objectives of this system:

 Maintain the information about students.

 Maintain the details of staff members.

 Maintain the Software user details

 Record the various kinds of fees details.

 Maintain the back-up o of software.

 Provide various reports like fee report, student report etc.

Page9|
PROJECT CATEGORY M E R N

The Java is a programming language originally developed by James Gosling


at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and
released in 1995 as a core component of Sun Microsystems' Java platform.
The language derives much of its syntax from C and C++ but has a simpler
object model and fewer low-level facilities. Java applications are typically
compiled to bytecode (class file) that can run on any Java Virtual Machine
(JVM) regardless of computer architecture. Java is general-purpose,
concurrent, class-based, and object-oriented, and is specifically designed to
have as few implementation dependencies as possible. It is intended to let
application developers "write once, run anywhere". Java is considered by
many as one of the most influential programming languages of the 20th
century, and widely used from application software to web application.[9]
[10]

The original and reference implementation Java compilers, virtual


machines, and class libraries were developed by Sun from 1995. As of May
2007, in compliance with the specifications of the Java Community Process,
Sun relicensed most of their Java technologies under the GNU General
Public License. Others have also developed alternative implementations of
these Sun technologies, such as the GNU Compiler for Java and GNU
Classpath.

P a g e 10 |
ADVANTAGES OF JAVA

1. Java is simple: Java was designed to be easy to use and is therefore


easy to write, compile, debug, and learn than other programming
languages. The reason that why Java is much simpler than C++ is
because Java uses automatic memory allocation and garbage
collection where else C++ requires the programmer to allocate
memory and to collect garbage.

2. Java is object-oriented: Java is object-oriented because


programming in Java is centered on creating objects, manipulating
objects, and making objects work together. This allows you to create
modular programs and reusable code.

3. Java is platform-independent: One of the most significant


advantages of Java is its ability to move easily from one computer
system to another.

4. Java is distributed: Distributed computing involves several


computers on a network working together. Java is designed to make
distributed computing easy with the networking capability that is
inherently integrated into it.

P a g e 11 |
5. Java is interpreted: An interpreter is needed in order to run Java
programs. The programs are compiled into Java Virtual Machine code
called bytecode.

6. Java is secure: Java is one of the first programming languages to


consider security as part of its design. The Java language, compiler,
interpreter, and runtime environment were each developed with
security in mind.

7. Java is robust: Robust means reliable and no programming language


can really assure reliability. Java puts a lot of emphasis on early
checking for possible errors, as Java compilers are able to detect
many problems that would first show up during execution time in
other languages.

8. Java is multithreaded: Multithreaded is the capability for a


program to perform several tasks simultaneously within a program.
In Java, multithreaded programming has been smoothly integrated
into it, while in other languages, operating system-specific
procedures have to be called in order to enable multithreading.

P a g e 12 |
TOOLS/PLATFORM REQUIRED

Operating System

 Windows XP ,Windows 7.

HARDWARE & SOFTWARE REQUIREMENTS

Hardware Requirements:

 Pentium IV Processor

 512 MB RAM

 80 GB Hard Disk

Software Requirements:

 JDK 5.0

 MySQL

 Notepad/Editor

 Netbeans 7.0

P a g e 13 |
PROBLEM DEFINITION

To maintain the record of students, staffs, fees, and various users, in


order to help the school administration.

REQUIREMENT SPECIFICATIONS

A Software Requirements Specification (SRS) is a complete description of


the behavior of the system to be developed. It includes a set of use cases
that describe all the interactions the users will have with the software. Use
cases are also known as functional requirements. In addition to use cases,
the SRS also contains non-functional (or supplementary) requirements.
Non-functional requirements are requirements which impose constraints
on the design or implementation (such as performance engineering
requirements, quality standards, or design constraints).

The general requirements of the project are:

 To maintain the admission details.

 To keep track the staff and students details.

 To record User details.

 To keep the record of various types of fee details.

 To keep the back-up of important data.

PROJECT PLANNING & SCHEDULING

P a g e 14 |
Project planning is part of project management, which relates to the use of
schedules such as Gantt charts to plan and subsequently report progress
within the project environment.

Initially, the project scope is defined and the appropriate methods for
completing the project are determined. Following this step, the durations
for the various tasks necessary to complete the work are listed and grouped
into a work breakdown structure. The logical dependencies between tasks
are defined using an activity network diagram that enables identification of
the critical path. Float or slack time in the schedule can be calculated using
software. Then the necessary resources can be estimated and costs for each
activity can be allocated to each resource, giving the total project cost. At
this stage, the project plan may be optimized to achieve the appropriate
balance between resource usage and project duration to comply with the
project objectives. Once established and agreed, the plan becomes what is
known as the baseline. Progress will be measured against the baseline
throughout the life of the project. Analyzing progress compared to the
baseline is known as earned value management.

The PROJECT SCHEDULE is a calendar that links the tasks


to be done with the resources that will do them. Before a project schedule
can be created, the project manager must have a work breakdown structure
(WBS), an effort estimate for each task, and a resource list with availability
for each resource. If these are not yet available, it may be possible to create
something that looks like a schedule, but it will essentially be a work of
fiction. A project manager’s time is better spent on working with the team
to create a WBS and estimates (using a consensus-driven estimation
method like Wideband Delphi than on trying to build a project schedule
without them. The reason for this is that a schedule itself is an estimate:
each date in the schedule is estimated, and if those dates do not have the
buy-in of the people who are going to do the work, the schedule will almost
certainly be inaccurate.

P a g e 15 |
GANTT CHART

Gantt charts (developed by Henry L. Gantt) are a project control technique


that can be used for several purposes including scheduling, budgeting and
resource planning. A Gantt chart is a bar chart with each bar representing
an activity.

The bars are drawn against a time line. The length of each bar is
proportional to the length of time planned for the activity. Gantt chart can
take different phase depending on their intended use. The Gantt chart of
School Management System is drawn for the time management. The
Gantt chart is drawn below:

P a g e 16 |
YEAR 2015
15st Mar 31st March 1st April 30th April 1st May 31th May

Start

ANALYSI

DESIGN DATABASE(BACKEND)

Design of NMS different form (Front End)

Code data base part

Code Part of NMS

Report

Write Manual

Integration & Testing

Finish

P a g e 17 |
PERT CHART

PERT (Project Evaluation and Review Technique) charts consist of a


network of boxes and arrows. The boxes represent activities and the arrows
represent task dependencies.

PERT is organized by events and activities or tasks. PERT have more


advantages and they are likely to be used for more complex projects.
Through PERT chart the various task paths are defined. PERT enables the
calculation of critical path. Each path consists of combination of tasks,
which must be completed. The time and the cost associated with each task
along a path are calculated, and the path that requires the greatest amount
of elapsed time is the critical path. Calculation of the critical path enables
project manager to monitor this series of task more closely than others to
shift resources to it, if it begins to fall behind schedule.

PERT controls time and cost during the project and also facilitate
finding the right balance between completing a project on time and
completing it within the budget. There are thus not one but many critical
paths, depending on the permutations of the estimates for each task. This
makes analysis of critical path in PERT charts very complex. The PERT
chart representation of the School Management System is shown below.

31st March 30th April 1st May 31st May

Analysis Design Code Pa


Integrate e 18 |
Part Part Database and Test
Part
15th March
SYSTEM ANALYSIS

IDENTIFICATION OF NEED

To Important Indication for software we use the Principles of


Requirement Engineering. Requirement engineering provides the
appropriate mechanism for understanding what the customer wants,
analyzing need, assessing feasibility, negotiating a reasonable solution,
specifying the solution unambiguously, validating the specification and
managing the requirement as they are transformed into an operational
system. The requirement engineering process can be described in five
distinct steps:

Requirement elicitation.

Requirement analysis & negotiation.

Requirement specification.

System Modeling.

Requirement validation.

Requirement Management.

Page1|
In other words we can say that requirement analysis is a software
task that bridges the gap between system level requirement
engineering and software design.

Requirement analysis allows the software engineering to refine


the software allocation and build models of the data, functional and
behavioral domains that will be treated by software. Requirement
analysis provides the software designer with a representation of
information, function and behavior that can be translated into data,
architectural, interface and component level design; finally the
requirement specification provides the developer and the customer
with the means to assess quality once software is built.

The most commonly used requirement elicitation technique is to


conduct a meeting or interview. The first meeting between a software
engineer and customer can be likened to the awareness of a first date
between to adolescents. Neither person knows what to

say or ask; Both are worried that what they do say will be
misinterpreted; both are thinking about where it might lead (Both
likely have radically different expectation here); Both want to get the
think over with, but at the same time, both want it to be a success.

Here according to this principle the analyst starts by asking


context-free-questions. That is a set of question that will lead to a
basic understanding of the problem, the people who want a solution,
the nature of solution that is desired, and the effectiveness of the first

Page2|
encounter itself. The first set of Context-free question focuses on the
customer, the overall goals, and the benefits. For example, the analyst
might ask: -

Who is behind the request for this Work?

Who will use the solution?

What will be economic benefit of a successful solution?

Is there another source for the solution that you need?

The next set of questions enables the software engineer to gain a


better Understanding of the problem and the customer to voice his or
her perceptions about a solution: -

How would you characterize “good” output that would be generated by


a successful solution?

What problem(s) will this solution address?

Can you show me (or describe) the environment in which the solution
will be used?

Will special performance issues or constraints affect the way the


solution is approached?

The final set of question focuses on the effectiveness of the meeting:

Page3|
Are you the right person to answer these questions? Are your answers?
Official”?

Are my questions relevant to the problem that you have?

Am I asking too many questions?

Can anyone else provide additional information?

Should I be asking you anything else?

According to the above concepts I went to institution and met its


staffs, management, and some persons related with the organizational
work, which advised me related with my project such as details of
agent, policy related information will be cater this system.

Preliminary Investigation: -

The first step in the system development life cycle is the


preliminary investigation to determine the feasibility of the System.
The purpose of the preliminary investigation is to evaluate project
requests. It is not a design study nor does it includes the collection of
details top describe the business system in all respect. Rather, it is
collecting of information that helps committee members to evaluate
the merits of the project request and make an informed judgment
about the feasibility of the proposed project.

Page4|
Here for the Ngo Management System, I have worked on the
preliminary investigation that accomplished the following objectives: -

Clarify and understand the project request.

Determine the size of the project.

Assess costs and benefits of alternative approaches.

Determine the technical and operational; feasibility of alternative


approaches.

Report the findings to management, with recommendation outlining


the acceptances or rejection of the proposal.

Considering above criteria I also keep in mind that the


requirements are clearly understandable when the clarification of
project request is enquired. The data of the Ngo Management System,
which are collected by me during preliminary investigation, are
through Reviewing organization Documents Onsite observation and

Conducting interviews.

Page5|
FEASIBILITY STUDY

Not everything imaginable is feasible, not even in software, even as


it may appear to outsiders. Feasibility is the determination of whether
or not a project is wrong doing. On the contrary, software feasibility
has seven solid dimensions as below: -

 Technical feasibility.
 Operational feasibility.
 Economic feasibility.
 Social feasibility.
 Management feasibility.
 Legal feasibility.
 Time feasibility.

The process followed in making this determination is called a


feasibility study. The type of study determines if a project can and
should be taken. Once it has been determined that a project is feasible,
that analyst can go ahead and prepare the project specification which
finalizes project requirements. Generally, feasibility studies are
undertaken within tight time constraints and normally culminate in a
written and oral feasibility report. The contents and recommendation
of such a study will be used as a sound basis for deciding whether to
proceed, postpone or cancel the project. Thus, since the feasibility
study may lead to the commitment of large resources, it becomes

Page6|
necessary that it should be conducted competently and that no
fundamental errors of judgment are made.

In other words we can say that a feasibility study is conducted to select


the best system that meets performance requirement. This contains
and identification description, an evaluation of candidate system and
the selection of best system for the job. The system required a
statement of constraints; the identification of specific system objective
and a description of outputs define performance.

TECHNICAL FEASIBILITY: -

Technical feasibility is concerned with specifying equipment and


software that will successfully satisfy the user requirements. My
project is fit in technical feasibility because it requires neither too
much heavy configuration system for its run nor in its development.

Following hardware and software components are used in the


development of proposed system.

The same configuration system is also meets all the requirements


to run or for implements to run or for implementation of the system.
Though I have also tested this software for that systems whose
configuration is lower than the above specified

ECONOMICAL FEASIBILITY: -

Economic analysis is the most frequently used technique for


evaluation of the effectiveness of a proposed system. More commonly

Page7|
known as Cost/Benefit analysis, the procedure is to determine the
benefits and saving that are expected from a proposed system and
compare them with costs. If benefits outweigh costs, a decision is
taken to design and implement the system. Other weight costs, a
decision is taken to design and implement the system. Otherwise,
further justification or alternative in the proposed system will have to
be made if is to have a chance of being approved. This is an ongoing
effort that improves in accuracy at each phase of the system life cycle.

Before establishing Economical Feasibility so as to justify the


expenses that different organization working under this category has
to bear for this Software. It is crystal clear that the user or Customer of
this Software has no need to invest heavy amount for this software. As
my project has been written in such a language, which is a platform
Independent. It has also the feature of WORM. It means it possess
the technology of Write Once & Read Many.

There is no any heavy expense on the maintenance of this


Software. Also there is no need to expense a heavy amount on the set
of “Very Expert Personals” because it is very easy and user-friendly
software. It is fully tighten protection of Secret Password and User
Name for unauthorized access of this Software.

For different types of Process or Operation, Reports or Query


and Output also, there is no need of heavy expenditure.

OPERATIONAL FEASIBILITY: -

Page8|
My project is also fit in Operational Feasibility Study. As I have
explained before this about Technical Feasibility and Economical
Feasibility, this Software is very easy and user-friendly.

I have used a very easy menu system and also used some control
buttons in the easy way by which one can choose the options on his
desire.

Though this is fully protected with the security by word


(Password and user name), if both are matched only then one can get
access of this software.

Various Reports, Forms and Queries can be generated on the


fingertips for the user.

In nutshell we can say that it has following operational features:

1. It is User-Friendly.
2. It is having less paperwork.
3. Efficient tractability.
4. Query can be generated.
5. Various Reports and Forms can be generated.
6. Fully protected by Password and User name for unauthorized
access.

Page9|
ANALYSIS

System Analysis refers into the process of examining a situation


with the intent of improving it through better procedures and
methods. System Analysis is the process of planning a new System to
either replace or complement an existing system.
DFD
The DFD is an excellent communication tool for analysts to model processes and functional
requirements. Used effectively, it is a useful and easy to understand modeling tool. It has broad application

OPERATOR OF SCHOOL ENQURY DETAIL

View/Delete
FEE DETAIL

STUDEN
Demand T
STUDENT REGISTRATION

Add/Update
View/ Print
STUDENT DETAILS
REPORT

STUDENT REGISTRATION OPERATOR GENERATE

P a g e 10 |
REPORT

DFD 2: MAINTAIN STUDENT RECORD

P a g e 11 |
ACCOUNTANT

LIBRARY CHARGE

FEE REGISTRATION CHARGE

TUTION CHARGE
View & Print
OTHER CHARGE ADDMITION CHARGE

PAYMENT MODE

STUDENT REGISTRATION OPERATOR GENERATE REPORT

DFD 3: MAINTAIN FEE RECORD

P a g e 12 |
P a g e 13 |
OPERATOR OF SCHOOL
DESIGNATION

V View/Delete/Search
Enter Update EMPLOYEE DETAIL
Demand EMPLOUYpEdEate

View & Print

STAFF OPERATOR REPORT


REGISTRATION GENERATE

DFD 4: MAINTAIN EMPLOYEE RECORD

P a g e 14 |
MODULE DESCRIPTION

These are the following Modules in the project:-

1. STUDENT :- This module is used for the information about the


students through which it can be considered for particular
student information as roll_no, address, course, admission status
etc. In this module admission, student record updation , deletion
etc happen.

2. STAFF/EMPLOYEE :- This module consists, the information


about employees (working members) in the college for their
different posts as faculties, coordinator, peon and other teaching
& non-teaching staffs.

3. FEE : - This module maintains the information of student’s


admission fee , monthly fee and different type of fee Dues etc.

4. SETTING :- It is necessary to maintain the security level by


implementing the concept of user authentication checking. The
security module deals with user authentication and security
measures. In which the user login id and password is used to
secure & maintain the protection feature.

5. REPORT :-This module is used to view or print different type of


Report like admission details, fee details etc.

P a g e 15 |
DATA STRUCTURE SNAP SHOT

DATA DICTIONERY:- The data dictionary stores description of


data items and structures, as well as systems processes. Data dictionary
used for database design in this project is mentioned. Care was taken
during the database design for future expansion of school’s need.

User_ Details (Login)

P a g e 16 |
Student Details (student_add):

P a g e 17 |
Staff Details (Staff_add):-

Fee Structure (fees):

P a g e 18 |
Admission fees (addfees):

P a g e 19 |
Monthly fees(transaction):-

P a g e 20 |
LIST OF REPORTS

The following reports will be generated:-

P a g e 21 |
1. Registration: - This report contains the information of all
registered students of the school.

2. Fee: - In this report, the fee details will be displayed.

SCOPE AND FUTURE ENHANCEMENT

There is always a scope of betterment and the candidate


system is not against perception. The project uses very nearly the same
calculations as School does; if clients want any other type of changes it
can also be done because the project is upgradeable.

The project can be used as a sub-project for any other projects. The
main future scope is as follows:-

🞛 To Store the large amount of data for future point of view.

🞛Reducing manual efforts for maintain the system.

🞛 Reducing the lead time.

🞛It gives correct information about Student details, Staff details, Fee
etc.

IMPLEMENTATION METHODOLOGY

Implementation of a tested system is done on the actual location


with the actual hardware, Software and manpower platforms or

P a g e 22 |
limitation. To implement of this software, the followings are the
necessary:

This project run on internet or intranet , so I have to selected


internet supportive software. For implementing this software a web-
server is required . I have to install IIS(internet information service).
Know this project is web-based so it will need a web-browser which
will act as its interface, so for this project install a web-browser capable
of providing proper interface to this project such as internet
Explorer/mozilla Firefox/opera e.t.c and many other browser.and for
back-end operation ,I have to install ORACLE 9i which handle all the
work related to database query and updation as required by the
sostware. In future also use better databases.we know that this project
will be developed on heavy platform ASPJAVA with c# , so there is
requirement of advance processer and proper RAM and other advance
Hardware configuration.

 Create separate user for this application: A user named as


“admin” with the password “pass” is to be created for storing the
data in a separate place. Storing data under separate user will
protect the data. Oracle Navigator can be used for creating the
said username and password.
 Create required tables: The structure of tables required for this
project (Detail given in the data base design section) is to be
created in the said user. The SQL statement CREATE can be used
for creating such tables.
P a g e 23 |
 Create Distributable set of files: An installation package of the
software is to be built for implementation of the project at
desired location.

TESTING

Software testing consists of the following stages.

a) TEST PLAN DEVELOPMENT:-

The importance of software testing and its implications need not


be emphasized. Software testing is a critical element of software
quality assurance and represents the ultimate review of specifications,
design and coding. The main objective of testing is to uncover a host of
errors, systematically, with minimum effort and time. It improves the
reliability of the software.

b) TESTING STRATEGY:-

A testing strategy explains how to conduct a test to uncover all the


errors with minimum possible time and effort. It should be flexible
enough to promote customization that may be necessary in due course
of development process.

c) UNIT TESTING:-

Unit testing focuses verification effort on the smallest unit of software


module using the detailed design criteria. Process specifications testing
are done to uncover errors within the boundaries of the module. All

P a g e 24 |
modules must be successful in the unit test before start of the
integration testing. The software developed for e-banking is tested
module wise by giving normal values and extreme values as input. All
the bugs have been identified and removed. The software designed is
tested module wise. Before using the software, an employee has to give
organization name and password.

In the next stage he has to provide division name, employee ID and


password. If any of this information is wrong, the system gives an error
message- “invalid user and password”

INTEGRATION TESTING:-

It is a systematic technique for constructing different program


module in to an integrated software structure. This test uncovers the
errors during integration process. The integration aspect is tested after
integrating all the modules and validated.

VALIDATION TESTING:-

After the culmination of integration testing the software is ready as


per the specification. But it has to be validated as per the specification
and to uncover the unexpected future errors and to improve its
reliability. The random value and boundary values as input is fed to
the software developed and studied the software performance and
validated

P a g e 25 |
TEST CASE DESIGN

The techniques that are used in deriving the test cases are explained
below.

CONDITION TESTING:-

Condition testing is a test case design method that exercises the


logical conditions contained in the program. The possible components
in a condition statement are a Boolean operator, Boolean variable,
relational operator, arithmetic expression and parenthesis.

BOUNDARY VALUE ANALYSIS:-

Boundary value analysis leads to the selection of test cases that


exercise the boundary conditions or boundary values. It is observed
that a large number of errors tend to appear at the boundaries of the
input domain than in the center.The boundary condition is tested by
inserting values beyond specification/availability of project allocations.
E.g.the software is tested by giving more amount of money in the
indent form than available in the budget. Under this conciliation the
software gives an error message stating that insufficient fund.

EQUIVALENCE PARTITIONING:-

Equivalence portioning is a black box testing method that


divides the input domain of a program into classes of data from which

P a g e 26 |
test cases can be derived. A typical test uncovers a class errors might
otherwise require many more test cases before the error is observed.
Equivalence classes for input determine the valid and invalid inputs for
the program

LIMITATIONSANDFURTHER ENHANCEMENTS

LIMITATIONS:

Despite tremendous growth potentialities continues with a series of


challenges and contradictions in its implementations. The main
shortcomings are mentioned below.

 Easy transaction of money.


 Reliability of electronic payment system.
 Accounting, legal, taxation and security issues etc.

RECOMMENDED AREAS FOR FURTHER RESEARCH

Considering the fact that has already gone ahead the following areas
needs to be further probed for improving the system to meet the
changing scenario.

1) There is a lot of scope for future research in the areas like


automatic component/material planning, automatic advanced

P a g e 27 |
indenting, micro transactions, and customer relationship
management.

2) Components like electronic payment system, digital certificates,


electronic tokens, electronic cheques etc. are still in an
embryonic stage of development. This area opens up a lot of
scope for further research.

In the absence of universal standards for electronic transactions, the


organization should develop a standard internal to it and that translate
between its formats and those supported by its trading partners. This
approach reduces dependence on industry schedules for adopting
standards, and avoids the pitfalls of an organization-imposed solution.

SECURITY MECHANISM

Implementation of security is a key issue in any software


development different application use different kind of security
mechanism according to their need.In Ngo Management Systemthe
implementation of security has been confined up to the user level. The
“Ngo Management System” authenticates a user by its username and

P a g e 28 |
password to a user. A user is able to work on the software if s/he is an
authorized user with user id and password.

It is the system administrator who is responsible for granting


permission to any user. He can grant as well as revoke permissions
from any user.Another important security level is data level. In the
data level security defined validation and constraints in the database.
Due to this only valid data can be entered in the tables.

All information and management forms are stored within the


system, and access to this sensitive information is controlled through
an effective authentication system: one has to know the USER ID, and
PASSWORD to gain access to any of the information.

The management (administrator) can create new user, while a


normal user can’t do this. This system will provide the facility to
change the password according to the user need. For security measure
the ‘Password’ field will be taken as ‘Varchar2’ data type, so that a user
can use in this field both integer and alphabets.

SNAPSHOTS

P a g e 29 |
LOGIN FORM (login.java)

code for login page :-

import javax.swing.JOptionPane;

import java.sql.*;

public class login extends javax.swing.JFrame {

//ResultSet rs;

/**

* Creates new form login

*/

public login() {

initComponents();

/**

* This method is called from within the constructor to initialize the form.

* WARNING: Do NOT modify this code. The content of this method is always

P a g e 30 |
* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-


BEGIN:initComponents

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

txtuser = new javax.swing.JTextField();

jLabel3 = new javax.swing.JLabel();

txtpass = new

javax.swing.JPasswordField(); login = new

javax.swing.JButton();

jLabel4 = new javax.swing.JLabel();

jLabel5 = new javax.swing.JLabel();

jLabel6 = new

javax.swing.JLabel(); jLabel8 =

new javax.swing.JLabel(); jLabel7 =

new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder(new
java.awt.Color(204, 204, 204), new java.awt.Color(204, 204, 204)));

P a g e 31 |
jLabel1.setBackground(new java.awt.Color(0, 204, 102));

jLabel1.setFont(new java.awt.Font("Viner Hand ITC", 1, 14)); // NOI18N

P a g e 32 |
jLabel1.setForeground(new java.awt.Color(102, 102, 102));

jLabel1.setText("LOGIN - Panel");

jLabel2.setFont(new java.awt.Font("Tempus Sans ITC", 0, 14)); // NOI18N

jLabel2.setText("USER ID :");

txtuser.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

jLabel3.setFont(new java.awt.Font("Tempus Sans ITC", 0, 14)); // NOI18N

jLabel3.setText("PASSWORD :");

login.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow"
));

login.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

login.setText("Submit");

login.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

loginActionPerformed(evt);

});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme

nt.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()

P a g e 33 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)

.addComponent(login, javax.swing.GroupLayout.PREFERRED_SIZE, 78,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(53, 53, 53)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)

.addComponent(jLabel3)

.addComponent(jLabel2))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21,
Short.MAX_VALUE)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)

.addComponent(txtuser, javax.swing.GroupLayout.PREFERRED_SIZE, 130,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(txtpass, javax.swing.GroupLayout.PREFERRED_SIZE, 130,


javax.swing.GroupLayout.PREFERRED_SIZE))))

.addGap(62, 62, 62))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()

.addGap(0, 0, Short.MAX_VALUE)

.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 121,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(101, 101, 101))

);

jPanel1Layout.setVerticalGroup(

P a g e 34 |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jLabel1)

.addGap(38, 38, 38)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)

.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 31,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(txtuser, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(36, 36, 36)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)

.addComponent(jLabel3)

.addComponent(txtpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33,
Short.MAX_VALUE)

.addComponent(login)

.addGap(19, 19, 19))

);

jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/child.jpg"))); //
NOI18N

jLabel5.setFont(new java.awt.Font("Baskerville Old Face", 1, 18)); // NOI18N

jLabel5.setForeground(new java.awt.Color(153, 0, 0));

jLabel5.setText("JAWAHAR NAVODAYA VIDYALA - School Management Software");

P a g e 35 |
jLabel6.setFont(new java.awt.Font("Trebuchet MS", 1, 14)); // NOI18N

jLabel6.setText("Is created by Sandip Kumar & Bhaskar kumar,Neha kumari,Puja


Bharti.");

jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/login.jpg"))); //
NOI18N

jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

jLabel7.setText(" Guided by Mr. Neeraj Kumar Singh");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA

DING)

.addGroup(layout.createSequentialGroup()

.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL
ING)

.addGroup(layout.createSequentialGroup()

.addGap(31, 31, 31)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)

.addComponent(jLabel5)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
TRAILING)

.addComponent(jLabel7)

.addComponent(jLabel6)))

P a g e 36 |
.addGap(114, 114, 114))

.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()

.addGap(62, 62, 62)

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 132,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap())))

);

layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN

G)

.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()

.addGap(43, 43, 43)

.addComponent(jLabel5)

.addGap(18, 18, 18)

.addComponent(jLabel6)

.addGap(18, 18, 18)

.addComponent(jLabel7)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL
ING)

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

P a g e 37 |
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 227,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(137, 137, 137))

);

pack();

}// </editor-fold>//GEN-END:initComponents

private void loginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_loginActionPerformed

Statement st;

Connection cn;

ResultSet rs;

String user,pass,name;

user=txtuser.getText().toLowerCase();

pass=txtpass.getText();

try

Class.forName("com.mysql.jdbc.Driver");

cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","bhaskar");

st=cn.createStatement();

String sql="Select* from login where user='"+user+"' and password='"+pass+"'";


rs=st.executeQuery(sql);
if(rs.next())
{
JOptionPane.showMessageDialog(rootPane,"Login Successful");
name=rs.getString("name");

P a g e 38 |
if(user.equals("admin"))
{
new main_admin().show();
this.dispose();
}
else
{
main_user obj= new main_user();

obj.hello.setText("WELCOME "+name);

obj.setVisible(true);

this.dispose();
}
}

else

{
sql="Select* from login where user='"+user+"'";
rs=st.executeQuery(sql);
if(rs.next())
{

JOptionPane.showMessageDialog(rootPane,"password is wrong");

}
else
{
JOptionPane.showMessageDialog(rootPane,"User is wrong");
}
// JOptionPane.showMessageDialog(null, "Invalid Login");
txtpass.setText(null);
}
}

catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
// TODO add your handling code here:

P a g e 39 |
}//GEN-LAST:event_loginActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new login().setVisible(true);
}

P a g e 40 |
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel
jPanel1; private
javax.swing.JButton login;
private javax.swing.JPasswordField
txtpass; private javax.swing.JTextField
txtuser;
// End of variables declaration//GEN-END:variables
}

P a g e 41 |
MAIN FORM (main_admin.java) for admin :

code :
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
public class home extends javax.swing.JFrame {

P a g e 42 |
/**
* Creates new form home
*/
public home() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel2 = new javax.swing.JPanel();


jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jMenuBar1 = new
javax.swing.JMenuBar(); jMenu1 = new
javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem5 = new javax.swing.JMenuItem();
jMenuItem24 = new javax.swing.JMenuItem();
jMenuItem26 = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem6 = new javax.swing.JMenuItem();
jMenuItem7 = new javax.swing.JMenuItem();
jMenuItem8 = new javax.swing.JMenuItem();
jMenuItem27 = new javax.swing.JMenuItem();
jMenu4 = new javax.swing.JMenu();
jMenuItem12 = new javax.swing.JMenuItem();
jMenuItem21 = new javax.swing.JMenuItem();
P a g e 43 |
jMenuItem22 = new javax.swing.JMenuItem();
jMenuItem23 = new javax.swing.JMenuItem();
jMenu7 = new javax.swing.JMenu();
jMenuItem28 = new javax.swing.JMenuItem();
jMenuItem29 = new javax.swing.JMenuItem();
jMenu5 = new javax.swing.JMenu();
jMenuItem9 = new javax.swing.JMenuItem();
jMenuItem10 = new javax.swing.JMenuItem();
jMenuItem11 = new javax.swing.JMenuItem();
jMenuItem15 = new javax.swing.JMenuItem();
jMenuItem14 = new javax.swing.JMenuItem();
jMenuItem13 = new javax.swing.JMenuItem();
jMenu6 = new javax.swing.JMenu();
jMenuItem19 = new javax.swing.JMenuItem();
jMenuItem20 = new javax.swing.JMenuItem();
jMenuItem25 = new javax.swing.JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);


jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);

jPanel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

jLabel1.setFont(new java.awt.Font("Trebuchet MS", 1, 14)); // NOI18N


jLabel1.setForeground(new java.awt.Color(153, 0, 0));
jLabel1.setText("Welcome to Administration Panel");

jLabel2.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/admission.png"))); // NOI18N
jLabel2.setText("jLabel2");

jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/human.png"))); //
NOI18N

jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/library.png"))); //
NOI18N

P a g e 44 |
jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/setting.png"))); //
NOI18N

jLabel6.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/studentde.png"))); // NOI18N

jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fees.png"))); //
NOI18N

jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jawaher.jpg")));
// NOI18N

jLabel9.setFont(new java.awt.Font("Baskerville Old Face", 1, 24)); // NOI18N


jLabel9.setForeground(new java.awt.Color(0, 102, 102));
jLabel9.setText("JAWAHAR NAVODAYA VIDYALAYA - School Management Software");

jLabel10.setForeground(new java.awt.Color(0, 102, 102));


jLabel10.setText("CREATED BY :");

jLabel11.setFont(new java.awt.Font("Tempus Sans ITC", 0, 14)); // NOI18N


jLabel11.setForeground(new java.awt.Color(0, 102, 102));
jLabel11.setText("Sandip jayaswal ");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(44, 44, 44)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 106,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addGap(36, 36, 36)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addComponent(jLabel6)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)

P a g e 45 |
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 113,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(51, 51, 51)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 819,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 810,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(132, 132, 132)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 234,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel10)
.addGap(18, 18, 18)
.addComponent(jLabel11)
.addGap(103, 103, 103))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jLabel9)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel10)
.addComponent(jLabel11)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 292,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()

P a g e 46 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
60, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel4)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 91,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(82, 82, 82)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 97,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(25, 25, 25))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(52, 52, 52)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 111,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(70, 70, 70)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 97,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);

jMenu1.setText("Student");

jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_A, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem1.setText("Admission");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);

jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_D, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem5.setText("Student Details");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);

P a g e 47 |
}
});
jMenu1.add(jMenuItem5);

jMenuItem24.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent
.VK_U, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem24.setText("Update Student profile");
jMenuItem24.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem24ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem24);

jMenuItem26.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent
.VK_D, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem26.setText("Delete Student Profile");
jMenuItem26.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem26ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem26);

jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_E, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem4.setText("Exit");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem4);

jMenuBar1.add(jMenu1);

jMenu2.setText("Teacher");

jMenuItem6.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_M, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem6.setText("Create faculty member");

P a g e 48 |
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem6);

jMenuItem7.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_F, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem7.setText("View Faculty Information");
jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem7ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem7);

jMenuItem8.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_I, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem8.setText("Update Faculty Information");
jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem8ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem8);

jMenuItem27.setText("Delete Teacher Profile");


jMenuItem27.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem27ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem27);

jMenuBar1.add(jMenu2);

jMenu4.setText("Fee management");

jMenuItem12.setText("Take student fees");


jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem12ActionPerformed(evt);

P a g e 49 |
}
});
jMenu4.add(jMenuItem12);

jMenuItem21.setText("Add fee structure");


jMenuItem21.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem21ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem21);

jMenuItem22.setText("monthly fees");
jMenuItem22.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem22ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem22);

jMenuItem23.setText("Mail Monthly Fee Report");


jMenuItem23.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem23ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem23);

jMenu7.setText("Student Fee Report");

jMenuItem28.setText("Monthly Report");
jMenu7.add(jMenuItem28);

jMenuItem29.setText("Yearly Report");
jMenu7.add(jMenuItem29);

jMenu4.add(jMenu7);

jMenuBar1.add(jMenu4);

jMenu5.setText("Setting");

jMenuItem9.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_U, java.awt.event.InputEvent.CTRL_MASK));

P a g e 50 |
jMenuItem9.setText("Create User");
jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem9ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem9);

jMenuItem10.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent
.VK_U, java.awt.event.InputEvent.SHIFT_MASK));
jMenuItem10.setText("Modify User");
jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem10ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem10);

jMenuItem11.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_D, java.awt.event.InputEvent.SHIFT_MASK));
jMenuItem11.setText("Delete User");
jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem11ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem11);

jMenuItem15.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_S, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem15.setText("Search User Information");
jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem15ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem15);

jMenuItem14.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_B, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem14.setText("Backup database");

P a g e 51 |
jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem14ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem14);

jMenuItem13.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_R, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem13.setText("Restore database");
jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem13ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem13);

jMenu6.setText("Change Password");

jMenuItem19.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_P, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem19.setText("User Password");
jMenuItem19.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem19ActionPerformed(evt);
}
});
jMenu6.add(jMenuItem19);

jMenuItem20.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent
.VK_P, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem20.setText("Admin password");
jMenuItem20.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem20ActionPerformed(evt);
}
});
jMenu6.add(jMenuItem20);

jMenu5.add(jMenu6);

P a g e 52 |
jMenuItem25.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent
.VK_H, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem25.setText("Help");
jMenuItem25.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem25ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem25);

jMenuBar1.add(jMenu5);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(0, 970, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 1167,
Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42))
);

pack();
}// </editor-fold>

P a g e 53 |
private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {
update_teacher_form myform = new update_teacher_form();
myform.setVisible(true);
// TODO add your handling code here:
}

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


if(JOptionPane.showConfirmDialog(rootPane, "Do you want to
Exit ?")==JOptionPane.YES_OPTION)
this.dispose();
// TODO add your handling code here:
}

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


studentdetail myform = new studentdetail();
myform.setVisible(true);
// TODO add your handling code here:
}

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

student_admission myform = new


student_admission(); myform.setVisible(true);
// TODO add your handling code here:
}

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


user_add myform = new user_add();
myform.setVisible(true);
// TODO add your handling code here:
}

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


try{

int processComplete; // to verify that either process completed or not

Process runtimeProcess = Runtime.getRuntime().exec("C:\\Program Files\\MySQL\\MySQL


Server 5.5\\bin\\mysqldump -u root -psandip school -r d:/backup.sql");

// call the mysqldump in terminal and execute it

processComplete = runtimeProcess.waitFor();//store the state in variable

P a g e 54 |
if(processComplete==1){//if values equal 1 process failed

JOptionPane.showMessageDialog(null, "Backup Failed");//display message


}

else if(processComplete==0){//if values equal 0 process failed

JOptionPane.showMessageDialog(null,"\n Backup created Successfully..\n Check the


Backup File in the D: Directory named as backup.sql");
//display message
}

}catch(Exception e){

JOptionPane.showMessageDialog(null,e);//exeception handling

}
// TODO add your handling code here:
}

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


user_information myform = new user_information();
myform.setVisible(true);
// TODO add your handling code here:
}

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


help myform = new help();
myform.setVisible(true);
// TODO add your handling code here:
}

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


update_student_profile myform = new update_student_profile();
myform.setVisible(true);
// TODO add your handling code here:
}

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


delate_student_profile myform = new delate_student_profile();
myform.setVisible(true);
// TODO add your handling code here:
}

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

P a g e 55 |
update_user_profile myform = new update_user_profile();
myform.setVisible(true);
// TODO add your handling code here:
}

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


teacher_registration myform = new teacher_registration();
myform.setVisible(true);
// TODO add your handling code here:
}

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


teacher_information myform = new teacher_information();
myform.setVisible(true);
// TODO add your handling code here:
}

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


change_user_password_form myform = new change_user_password_form();
myform.setVisible(true);

// TODO add your handling code here:


}

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


change_admin_password_form myform = new change_admin_password_form();
myform.setVisible(true);
// TODO add your handling code here:change_admin_password_form
}

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


add_fees_structure myform = new add_fees_structure();
myform.setVisible(true);
// TODO add your handling code here:
}

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

monthly_fees myform = new


monthly_fees(); myform.setVisible(true);
// TODO add your handling code here:
}

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


add_fees myform = new add_fees();

P a g e 56 |
myform.setVisible(true);
// TODO add your handling code here:
}

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


send_mail myform = new send_mail();
myform.setVisible(true);
// TODO add your handling code here:
}

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


delate_teacher_profile myform = new delate_teacher_profile();
myform.setVisible(true);
// TODO add your handling code here:
}

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


delate_user_profile myform = new delate_user_profile();
myform.setVisible(true);
// TODO add your handling code here:
}

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


help myform = new help();
myform.setVisible(true);
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;

P a g e 57 |
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(home.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(home.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(home.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(home.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new home().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenu jMenu5;
private javax.swing.JMenu jMenu6;

P a g e 58 |
private javax.swing.JMenu jMenu7;
private javax.swing.JMenuBar
jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem10;
private javax.swing.JMenuItem jMenuItem11;
private javax.swing.JMenuItem jMenuItem12;
private javax.swing.JMenuItem jMenuItem13;
private javax.swing.JMenuItem jMenuItem14;
private javax.swing.JMenuItem jMenuItem15;
private javax.swing.JMenuItem jMenuItem19;
private javax.swing.JMenuItem jMenuItem20;
private javax.swing.JMenuItem jMenuItem21;
private javax.swing.JMenuItem jMenuItem22;
private javax.swing.JMenuItem jMenuItem23;
private javax.swing.JMenuItem jMenuItem24;
private javax.swing.JMenuItem jMenuItem25;
private javax.swing.JMenuItem jMenuItem26;
private javax.swing.JMenuItem jMenuItem27;
private javax.swing.JMenuItem jMenuItem28;
private javax.swing.JMenuItem jMenuItem29;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JMenuItem jMenuItem9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
// End of variables declaration
}

P a g e 59 |
Student Admission form :

code :
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.*;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*

P a g e 60 |
* @author sand
*/
public class student_admission extends javax.swing.JFrame {

/**
* Creates new form student_admission
*/
public student_admission() {
initComponents();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
//get current date time with Date()
Date date = new Date();
txtadmissiondate.setText(dateFormat.format(date));

int i;
for(i=1;i<=31;i++)
{
cmbdate.addItem(i);

} for(i=1900;i<=2015;i+
+)
{
cmbyear.addItem(i);

Statement st;
Connection cn;
ResultSet rs;
String sql,p;
boolean q;
int addno;

sql = "select admissionno from studentinfo order by admissionno desc";


try {
Class.forName("com.mysql.jdbc.Driver");
cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root",
"sandip");
st = cn.createStatement();
rs = st.executeQuery(sql);

P a g e 61 |
if (rs.next()) {
addno = rs.getInt("admissionno");
addno = addno + 1;
} else {
addno = 1;
}
txtadmission.setText("" + addno);
} catch (Exception e) {
JOptionPane.showMessageDialog(rootPane, e.getMessage());
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

buttonGroup1 = new
javax.swing.ButtonGroup(); jPanel1 = new
javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new
javax.swing.JLabel();
cmbclass = new javax.swing.JComboBox();
cmbsection = new javax.swing.JComboBox();
txtroll = new javax.swing.JTextField();
txtadmission = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
P a g e 62 |
txtstudentname = new javax.swing.JTextField();

P a g e 63 |
txtfathername = new javax.swing.JTextField();
txtmothername = new javax.swing.JTextField();
txtfatheroccupation = new javax.swing.JTextField();
cmbdate = new javax.swing.JComboBox();
cmbmonth = new javax.swing.JComboBox();
cmbyear = new javax.swing.JComboBox();
rmale = new javax.swing.JRadioButton();
rfemale = new javax.swing.JRadioButton();
txtcontactno = new javax.swing.JTextField();
txtemail = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
txtpaddress = new javax.swing.JTextArea();
jLabel15 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jScrollPane2 = new
javax.swing.JScrollPane(); txtladdress = new
javax.swing.JTextArea();
txtpicturename = new
javax.swing.JTextField(); jLabel16 = new
javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
txtadmissiondate = new
javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle(" ");
addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
formMouseClicked(evt);
}
});
addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
formKeyPressed(evt);
}
public void keyTyped(java.awt.event.KeyEvent evt) {
formKeyTyped(evt);
}
});

jPanel1.setBackground(new java.awt.Color(204, 204, 204));

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createEtchedBorder(new java.awt.Color(204, 204, 204), new java.awt.Color(204, 204, 204)),
"Create Student Admission :", javax.swing.border.TitledBorder.CENTER,
P a g e 64 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14),
new java.awt.Color(153, 0, 0))); // NOI18N

P a g e 65 |
jLabel1.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N
jLabel1.setText("Class");

jLabel2.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel2.setText("Roll no");

jLabel3.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel3.setText("Section");

jLabel4.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel4.setText("Admission no");

cmbclass.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Pre


Nurcery", "Nurcery", "L.k.G", "U.K.G", "std - 1", "std - 2", "std - 3", "std - 4 ", "std - 5", "std -
6", "std - 7", "std - 8", "std - 9", "std - 10", "std - 11", "std - +2" }));

cmbsection.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Choose


one", "section - A", "section - B", "section - C", "section - D", "section - E", "section - F",
"section - G" }));
cmbsection.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmbsectionActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(81, 81, 81)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 52,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(87, 87, 87)
.addComponent(cmbclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(99, 99, 99)
.addComponent(jLabel3)
.addGap(79, 79, 79)
.addComponent(cmbsection, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(87, 87, 87)
.addComponent(jLabel2)
.addGap(72, 72, 72)

P a g e 66 |
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE, 88,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(66, 66, 66)
.addComponent(jLabel4)
.addGap(79, 79, 79)
.addComponent(txtadmission, javax.swing.GroupLayout.PREFERRED_SIZE, 88,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(86, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel1)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(cmbclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbsection, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(txtadmission, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(26, Short.MAX_VALUE))
);

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(new
java.awt.Color(240, 240, 240), null), null), "Fill Student Details",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS",
3, 12), new java.awt.Color(102, 0, 0))); // NOI18N

jLabel5.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel5.setText("Student Name :");

jLabel6.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel6.setText("Father's Name :");

jLabel7.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N

P a g e 67 |
jLabel7.setText("Mother's Name :");

jLabel8.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel8.setText("Father's Occupation :");

jLabel9.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel9.setText("Date of Birth :");

jLabel10.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel10.setText("Gender :");

jLabel11.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel11.setText("Contact No :");

jLabel12.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); //


NOI18N jLabel12.setText("E-Mail :");

jLabel13.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel13.setText("Permanent Address :");

jLabel14.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel14.setText("Local Address :");

txtstudentname.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtstudentnameKeyReleased(evt);
}
});

txtfathername.setText(" ");
txtfathername.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtfathernameKeyReleased(evt);
}
});

txtmothername.setText(" ");
txtmothername.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtmothernameKeyReleased(evt);
}
});

txtfatheroccupation.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {

P a g e 68 |
txtfatheroccupationKeyReleased(evt);
}
});

cmbdate.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Date" }));

cmbmonth.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Month",


"Jan", "Feb", "March", "April", "May", "June", "July", "August", "September", "October",
"November", "December" }));

cmbyear.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Year" }));


cmbyear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmbyearActionPerformed(evt);
}
});

buttonGroup1.add(rmale);
rmale.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N
rmale.setText("Male");

buttonGroup1.add(rfemale);
rfemale.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N
rfemale.setText("Female");

txtpaddress.setColumns(20);
txtpaddress.setRows(5);
txtpaddress.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtpaddressKeyReleased(evt);
}
});
jScrollPane1.setViewportView(txtpaddress);

jLabel15.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); //


NOI18N jLabel15.setText("Admission Date : ");

jButton2.setText("Browse ");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

P a g e 69 |
jButton1.setText("Submit");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

txtladdress.setColumns(20);
txtladdress.setRows(5);
txtladdress.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtladdressKeyReleased(evt);
}
});
jScrollPane2.setViewportView(txtladdress);

jLabel16.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/profilepic.png"))); // NOI18N

jButton3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jButton3.setText("Reset");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);


jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(25, 25, 25)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(jLabel15)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING, false)
.addComponent(jLabel10, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel9, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)

P a g e 70 |
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING, false)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.TRAILING)
.addComponent(txtmothername,
javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtfathername,
javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtfatheroccupation,
javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtstudentname,
javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(67, 67, 67))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(63, 63, 63)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addComponent(txtadmissiondate,
javax.swing.GroupLayout.PREFERRED_SIZE, 197,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(cmbdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

P a g e 71 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRE
LATED)
.addComponent(cmbmonth,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELAT
ED)
.addComponent(cmbyear, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
50, Short.MAX_VALUE)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(81, 81, 81)
.addComponent(rmale)
.addGap(55, 55, 55)
.addComponent(rfemale)
.addGap(15, 15, 15)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 120,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
193, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(txtemail)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtcontactno, javax.swing.GroupLayout.DEFAULT_SIZE, 185,
Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtpicturename,
javax.swing.GroupLayout.PREFERRED_SIZE, 120,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(337, 337, 337))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 151,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 684, Short.MAX_VALUE))

P a g e 72 |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 136,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 151,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 151,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 119,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(109, 109, 109))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(32, 32, 32)
.addComponent(jButton3)
.addGap(64, 64, 64))
);
jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel5)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 14,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtstudentname,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(25, 25, 25)

P a g e 73 |
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel6)
.addComponent(txtfathername,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(27, 27, 27))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE,
20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtcontactno,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(13, 13, 13)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(txtmothername,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel13)
.addGap(3, 3, 3)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel8)
.addComponent(txtfatheroccupation,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 127,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

P a g e 74 |
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(cmbyear, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbmonth, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel10)
.addComponent(rmale)
.addComponent(rfemale)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(49, 49, 49)
.addComponent(jLabel14)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel15)
.addComponent(txtadmissiondate,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(96, 96, 96)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton3)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2)
.addGap(105, 105, 105))))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(59, 59, 59)

P a g e 75 |
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(txtpicturename, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(70, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);

pack();
}// </editor-fold>

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


Statement st1;
Connection cn1;
boolean q;

String admission,rollid,sname, fname, mname, foccupation, date,month,year, gender =


"", contactno, email, paddress, laddress, sclass, section, admissiondate,picturename;
int admissionno,rollno;

admission=txtadmission.getText();
admissionno =
Integer.parseInt(admission); rollid =
txtroll.getText();
rollno = Integer.parseInt(rollid);
// sclass = cmbclass.getSelectedItem().toString();
P a g e 76 |
// section = cmbsection.getSelectedItem().toString();
// sname = txtstudentname.getText();
// fname = txtfathername.getText();
//mname = txtmothername.getText();
// foccupation = txtfatheroccupation.getText();
// date=cmbdate.getSelectedItem().toString();
//month=cmbmonth.getSelectedItem().toString();
// year=cmbyear.getSelectedItem().toString();
if (rmale.isSelected())
{
gender = rmale.getText();
}
else if (rfemale.isSelected()) {
gender = rfemale.getText();
}
// admissiondate =txtpicturename.getText();
// admissiondate = dtpadmissiondate.getDate().toString();
// contactno = txtcontactno.getText();
//email = txtemail.getText();
// paddress = txtpaddress.getText();
// laddress = txtladdress.getText();
// picturename=jLabel16.getIcon();

try
{
Class.forName("com.mysql.jdbc.Driver");

cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st1=cn1.createStatement();
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to
Save ?")==JOptionPane.YES_OPTION)
{
// String p = "insert into studentinfo values(" + admissionno + "," + rollno + ",'" +
sclass + "','" + section + "','" + sname + "','" + fname + "','" + mname + "','" + foccupation + "','" +
date + "','" + month + "','" + year + "','" + gender + "','" + admissiondate + "','" + email + "','"
+contactno + "','" + paddress + "','" + laddress + "')";
String sql = "INSERT INTO studentinfo (admissionno, rollno, class , section , sname ,
fname , mname ,foccupation,dt,month, year ,
gender,admissiondate ,email,contactno,paddress,laddress,photo) values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

P a g e 77 |
PreparedStatement statement = cn1.prepareStatement(sql);

statement.setInt(1,admissionno );
statement.setInt(2,rollno);
statement.setString(3,cmbclass.getSelectedItem().toString() );
statement.setString(4,cmbsection.getSelectedItem().toString());
statement.setString(5,txtstudentname.getText());
statement.setString(6,txtfathername.getText());
statement.setString(7,txtmothername.getText());
statement.setString(8,txtfatheroccupation.getText());
statement.setString(9,cmbdate.getSelectedItem().toString());
statement.setString(10,cmbmonth.getSelectedItem().toString());
statement.setString(11,cmbyear.getSelectedItem().toString());
statement.setString(12,gender);
statement.setString(13,txtadmissiondate.getText());
statement.setString(14,txtcontactno.getText());
statement.setString(15,txtemail.getText());
statement.setString(16,txtpaddress.getText());
statement.setString(17,txtladdress.getText());
InputStream inputStream = new
FileInputStream(new File(txtpicturename.getText()));
statement.setBlob(18, inputStream);
int row =
statement.executeUpdate(); if (row >
0) {

JOptionPane.showMessageDialog(rootPane,"Record is Saved");
}
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}

// TODO add your handling code here:


}

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


JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
File f = chooser.getSelectedFile();
P a g e 78 |
String filename = f.getAbsolutePath();
txtpicturename.setText(filename);
BufferedImage bi;
try
{ //display the image in jlabel
bi=ImageIO.read(f);
jLabel16.setIcon(new ImageIcon(bi));
}
catch(IOException e)
{

}
// TODO add your handling code here:
}

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


String sclass,ssection,sql;
int rollno;

Connection cn;
Statement st;
ResultSet rs;

sclass= cmbclass.getSelectedItem().toString();
ssection=cmbsection.getSelectedItem().toString();

try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();

sql="select rollno from studentinfo where class='"+sclass+"' and section =


'"+ssection+"' order by rollno desc";

rs=st.executeQuery(sql);
if(rs.next())
{
rollno=rs.getInt("rollno");
rollno=rollno+1;

txtroll.setText(""+rollno);
}
else
{

P a g e 79 |
rollno=1;
txtroll.setText(""+rollno);
}

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

// TODO add your handling code here:


}

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


// TODO add your handling code here:
}

private void formKeyPressed(java.awt.event.KeyEvent evt) {

if(evt.getKeyCode() == evt.VK_C) {
JOptionPane.showMessageDialog(null,"click");
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); // trying
to close
} else {
System.out.println("not escaped");
}

private void formMouseClicked(java.awt.event.MouseEvent evt) {

private void formKeyTyped(java.awt.event.KeyEvent evt) {


JOptionPane.showMessageDialog(null,"click");
}

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


txtstudentname.setText(null);
cmbsection.setName("section - A");
// cmbclass.setModel(null);
//cmbsection.setModel(null);
txtstudentname.setText(null);

P a g e 80 |
txtfathername.setText(null);
txtmothername.setText(null);
txtfatheroccupation.setText(null);
//cmbdate.setModel(null);
// cmbmonth.setModel(null);
//cmbyear.setModel(null);
buttonGroup1.clearSelection();
// ImageIcon imgThisImg = new ImageIcon("profilepic.png");
// jLabel16.setIcon(imgThisImg);

txtpicturename.setText(null);
txtadmissiondate.setText(null);
txtcontactno.setText(null);
txtemail.setText(null);
txtpaddress.setText(null);
txtladdress.setText(null);

Statement st;
Connection cn;
ResultSet rs;

String sql;
int addno;

try
{
Class.forName("com.mysql.jdbc.Driver");

cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

//addno=Integer.parseInt(txtadd.getText());

st=cn.createStatement();

sql="select admissionno from studentinfo order by admissionno desc";


rs=st.executeQuery(sql);

if(rs.next())
{
addno=rs.getInt("admissionno");
addno=addno+1;
}
else
{
addno=1;

P a g e 81 |
}
txtadmission.setText(""+addno);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane, e.getMessage());
}

// TODO add your handling code here:


}

private void txtstudentnameKeyReleased(java.awt.event.KeyEvent evt) {


txtstudentname.setText(txtstudentname.getText().toUpperCase());
// TODO add your handling code here:
}

private void txtfathernameKeyReleased(java.awt.event.KeyEvent evt) {


txtfathername.setText(txtfathername.getText().toUpperCase());
// TODO add your handling code here:
}

private void txtmothernameKeyReleased(java.awt.event.KeyEvent evt) {


txtmothername.setText(txtmothername.getText().toUpperCase());
// TODO add your handling code here:
}

private void txtfatheroccupationKeyReleased(java.awt.event.KeyEvent evt) {


txtfatheroccupation.setText(txtfatheroccupation.getText().toUpperCase());
// TODO add your handling code here:
}

private void txtpaddressKeyReleased(java.awt.event.KeyEvent evt) {


txtpaddress.setText(txtpaddress.getText().toUpperCase());

// TODO add your handling code here:


}

private void txtladdressKeyReleased(java.awt.event.KeyEvent evt) {


txtladdress.setText(txtladdress.getText().toUpperCase());

// TODO add your handling code here:

P a g e 82 |
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(student_admission.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(student_admission.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(student_admission.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(student_admission.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new student_admission().setVisible(true);
}

P a g e 83 |
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup
buttonGroup1; private javax.swing.JComboBox
cmbclass; private javax.swing.JComboBox
cmbdate; private javax.swing.JComboBox
cmbmonth; private javax.swing.JComboBox
cmbsection; private javax.swing.JComboBox
cmbyear; private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane
jScrollPane2; private
javax.swing.JRadioButton rfemale; private
javax.swing.JRadioButton rmale; private
javax.swing.JTextField txtadmission;
private javax.swing.JTextField txtadmissiondate;
private javax.swing.JTextField txtcontactno;
private javax.swing.JTextField txtemail;
private javax.swing.JTextField txtfathername;
private javax.swing.JTextField txtfatheroccupation;
private javax.swing.JTextArea txtladdress;
private javax.swing.JTextField txtmothername;
private javax.swing.JTextArea txtpaddress;
private javax.swing.JTextField txtpicturename;
private javax.swing.JTextField txtroll;
P a g e 84 |
protected javax.swing.JTextField txtstudentname;
// End of variables declaration
}
Student Details form:

Code :
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.table.DefaultTableModel;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
import java.sql.*;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class studentdetail extends javax.swing.JFrame {

P a g e 85 |
/**
* Creates new form studentdetails
*/
public studentdetail() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jLabel2 = new javax.swing.JLabel();


jPanel3 = new
javax.swing.JPanel(); jPanel1 = new
javax.swing.JPanel(); jLabel1 = new
javax.swing.JLabel();
txtadmissionsearch = new javax.swing.JTextField();
jButton7 = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jButton1 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton8 = new
javax.swing.JButton(); jButton6 =
new javax.swing.JButton(); jButton5 =
new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);

jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/search.jpg"))); //
NOI18N

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createEtchedBorder(new java.awt.Color(204, 204, 204), null), "Update student Record :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
P a g e 86 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12),
new java.awt.Color(255, 0, 0))); // NOI18N

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel1.setText("Enter student Admission no :");

jButton7.setText("Search");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(63, 63, 63)
.addComponent(jLabel1)
.addGap(68, 68, 68)
.addComponent(txtadmissionsearch, javax.swing.GroupLayout.PREFERRED_SIZE,
182, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(43, 43, 43)
.addComponent(jButton7)
.addContainerGap(138, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(23, 23, 23)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel1)
.addComponent(txtadmissionsearch,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton7))
.addContainerGap(59, Short.MAX_VALUE))
);

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "All Records of


Student :", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12),
new java.awt.Color(153, 0, 0))); // NOI18N

P a g e 87 |
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {

},
new String [] {
"Admission no", "Student name", "Father's name", "Class", "Section", "Roll", "Contact
no"
}
));
jScrollPane1.setViewportView(jTable1);

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);


jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 702,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 38, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 215,
Short.MAX_VALUE)
);

jButton1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton1.setText("Show-details ");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton3.setText("Update");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jButton4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton4.setText("DELETE");

P a g e 88 |
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton2.setText("Admition");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jButton8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton8.setText("Preview");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});

jButton6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton6.setText("Print");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});

jButton5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton5.setText("Exit");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);


jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel3Layout.createSequentialGroup()
.addContainerGap(42, Short.MAX_VALUE)

P a g e 89 |
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(18, 18, 18)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(20, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jButton1)

P a g e 90 |
.addComponent(jButton3)
.addComponent(jButton4)
.addComponent(jButton2)
.addComponent(jButton8)
.addComponent(jButton6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38,
Short.MAX_VALUE)
.addComponent(jButton5)
.addContainerGap())
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(jLabel2)
.addContainerGap(785, Short.MAX_VALUE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(54, 54, 54)
.addComponent(jLabel2)))
.addContainerGap(184, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

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


DefaultTableModel model = ( DefaultTableModel)jTable1.getModel();
Statement st1;
boolean q;

P a g e 91 |
Connection
cn;
ResultSet rs;
String
temp,name,fname,mname,foccupation,dob,gender,contactno,paddress,laddress,sclass,sec
tion,roll,admissionno,admissiondate,photo;
int id=0;
int allot=0;
try
{
Class.forName("com.mysql.jdbc.Driver");

cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

st1=cn.createStatement();
String p="select admissionno,sname,fname,class,section,rollno,contactno from
studentinfo";
rs=st1.executeQuery(p);
while (rs.next())
{
admissionno= rs.getString("admissionno");
name= rs.getString("sname");
fname= rs.getString("fname");
sclass= rs.getString("class");
section= rs.getString("section");
id = rs.getInt("rollno");
contactno = rs.getString("contactno");
model.addRow(new
Object[]{admissionno,name,fname,sclass,section,id,contactno});
}
//DefaultTableModel model = (DefaultTableModel) table.getModel();
st1.close();

cn.close();

}
catch(Exception e)
{
System.out.println(e.getMessage());
}

// TODO add your handling code here:


}

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


student_admission myform = new student_admission();
P a g e 92 |
myform.setVisible(true);
// TODO add your handling code here:
}

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


if(JOptionPane.showConfirmDialog(rootPane, "Do you Want to
Exit ?")==JOptionPane.YES_OPTION)
this.dispose();
// TODO add your handling code here:
}

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


try {
if (! jTable1.print()) {
System.err.println("User cancelled printing");
}
} catch (java.awt.print.PrinterException e) {
System.err.format("Cannot print %s%n", e.getMessage());
}

// TODO add your handling code here:


}

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


{ int x=jTable1.getSelectedRow();
String d=jTable1.getValueAt(x,
0).toString(); String
n=jTable1.getValueAt(x, 1).toString();
Statement st1;
boolean q;
Connection cn;
ResultSet rs;
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

st1=cn.createStatement();

//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to Delete name =
"+n)==JOptionPane.YES_OPTION)

{
String p1="delete from studentinfo where admissionno='"+d+"'";

P a g e 93 |
st1.execute(p1);

//st1.execute(p1);

DefaultTableModel model = ( DefaultTableModel)jTable1.getModel();


model.removeRow(x);
}
st1.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}

// TODO add your handling code here:


}

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


int x=jTable1.getSelectedRow();

String d=jTable1.getValueAt(x,0).toString();
int id=Integer.parseInt(d);

//do the update query on this row

try {
Class.forName("com.mysql.jdbc.Driver");
if(JOptionPane.showConfirmDialog(rootPane, "Want to UPDATE Name=
"+d)==JOptionPane.YES_OPTION)
{
Connection cn=
DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
PreparedStatement ps = cn.prepareStatement("UPDATE studentinfo SET sname
= ? ,fname = ? ,mname = ?,foccupation = ?,dob = ?,gender = ?,contactno = ?,paddress
= ?,laddress = ?,class = ?,section = ?,roll = ?,admissiondate = ?,photo = ? WHERE
admissionno = "+id+""); //ps.setString(1, (String) jTable1. getValueAt(x, 0));

ps.setString(1, (String) jTable1.getValueAt(x, 1));


ps.setString(2, (String) jTable1.getValueAt(x, 2));
ps.setString(3, (String) jTable1.getValueAt(x, 3));
ps.setString(4, (String) jTable1.getValueAt(x, 4));
ps.setString(5, (String) jTable1.getValueAt(x, 5));
ps.setString(6, (String) jTable1.getValueAt(x, 6));
ps.setString(7, (String) jTable1.getValueAt(x, 7));

P a g e 94 |
ps.setString(8, (String) jTable1.getValueAt(x, 8));
ps.setString(9, (String) jTable1.getValueAt(x, 9));
ps.setString(10, (String) jTable1.getValueAt(x, 10));
ps.setString(11, (String) jTable1.getValueAt(x, 11));
ps.setString(12, (String) jTable1.getValueAt(x, 12));
ps.setString(13, (String) jTable1.getValueAt(x, 13));
ps.setString(14, (String) jTable1.getValueAt(x, 14));
ps.executeUpdate();
ps.close();
cn.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
// TODO add your handling code here:
}

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


Statement st;
Connection cn;
ResultSet rs;
String admission,rollid,studentname, fname, mname, foccupation,month, gender = "",
contactno, email, paddress, laddress, sclass, section, admissiondate,picturename;
int admissionno,date ,year;
admission=txtadmissionsearch.getText();
admissionno=Integer.parseInt(admission);
try
{
Class.forName("com.mysql.jdbc.Driver");

cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from studentinfo where admissionno ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{

sclass=rs.getString("class");
section=rs.getString("section");
rollid=rs.getString("rollno");
studentname=rs.getString("sname");
fname=rs.getString("fname");
mname=rs.getString("mname");
foccupation=rs.getString("foccupation");
date =rs.getInt("dt");

P a g e 95 |
//date = rs.getString("dt");
month=rs.getString("month");
year =rs.getInt("year");
gender=rs.getString("gender");
admissiondate=rs.getString("admissiondate");
contactno=rs.getString("contactno");
email=rs.getString("email");
paddress=rs.getString("paddress");
laddress=rs.getString("laddress");
java.sql.Blob blob = rs.getBlob("photo");
student_update myform = new student_update();
myform.txtadmissionno.setText(""+admissionno);
myform.cmbclass.setSelectedItem(sclass);
myform.cmbsection.setSelectedItem(section);
myform.txtroll.setText(rollid);
myform.txtstudentname.setText(studentname);
myform.txtfathername.setText(fname);
myform.txtmothername.setText(mname);
myform.txtfatheroccupation.setText(foccupation);

//myform.txtdob.setText(month);
//myform.txtdob.setText(year);
if(gender.equals("Male"))
{
myform.rmale.setSelected(true);
}
else
{
myform.rfemale.setSelected(true);
}
myform.cmbdate.setSelectedItem(date);
myform.cmbmonth.setSelectedItem(month);
myform.cmbyear.setSelectedItem(year);

myform.txtadmissiondate.setText(admissiondate);
myform.txtemail.setText(email);
myform.txtcontactno.setText(contactno);
myform.txtpermanentaddress.setText(paddress);

myform.txtlocaladdress.setText(laddress);
BufferedInputStream is2 = new BufferedInputStream(blob.getBinaryStream());
Image raw = ImageIO.read(is2);
ImageIcon icon = new ImageIcon(raw);
myform.spicture.setIcon(icon);

P a g e 96 |
//myform.f1t2.setText(f4t2.getText());
myform.setVisible(true);

// txtroll.setText(""+rollno);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}

// TODO add your handling code here:


}

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


// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(studentdetail.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (InstantiationException ex) {

P a g e 97 |
java.util.logging.Logger.getLogger(studentdetail.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(studentdetail.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(studentdetail.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new studentdetail().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextField txtadmissionsearch;
// End of variables declaration
}

P a g e 98 |
Student updation form :

Code :
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
public class update_student_profile extends javax.swing.JFrame {

/**
* Creates new form update_student_profile
*/
public update_student_profile () {
initComponents();

P a g e 99 |
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
txtadmissionno = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createEtchedBorder(new java.awt.Color(204, 204, 204), null), "Update Student Profile :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS",
1, 14), new java.awt.Color(0, 102, 102))); // NOI18N

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel1.setText("Enter Student ID :");

jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jButton1.setText("Search");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel1)
.addGap(53, 53, 53)

P a g e 100 |
.addComponent(txtadmissionno, javax.swing.GroupLayout.DEFAULT_SIZE, 186,
Short.MAX_VALUE)
.addGap(51, 51, 51)
.addComponent(jButton1)
.addGap(84, 84, 84))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(txtadmissionno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addComponent(jLabel1))
.addContainerGap(57, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addGap(48, 48, 48)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addGap(51, 51, 51)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(113, Short.MAX_VALUE))
);

setBounds(300, 57, 689, 365);


}// </editor-fold>

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


Statement st;

P a g e 101 |
Connection cn;
ResultSet rs;
String admission,rollid,studentname, fname, mname, foccupation,month, gender = "",
contactno, email, paddress, laddress, sclass, section, admissiondate,picturename;
int admissionno,date ,year;
admission=txtadmissionno.getText();
admissionno=Integer.parseInt(admission);
try
{
Class.forName("com.mysql.jdbc.Driver");

cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from studentinfo where admissionno ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{

rollid=rs.getString("rollno");
studentname=rs.getString("sname");
fname=rs.getString("fname");
mname=rs.getString("mname");
foccupation=rs.getString("foccupation");
date =rs.getInt("dt");
//date = rs.getString("dt");
month=rs.getString("month");
year =rs.getInt("year");
gender=rs.getString("gender");
admissiondate=rs.getString("admissiondate");
contactno=rs.getString("contactno");
email=rs.getString("email");
paddress=rs.getString("paddress");
laddress=rs.getString("laddress");
java.sql.Blob blob = rs.getBlob("photo");
student_update myform = new student_update();
myform.txtadmissionno.setText(""+admissionno);
myform.txtroll.setText(rollid);
myform.txtstudentname.setText(studentname);
myform.txtfathername.setText(fname);
myform.txtmothername.setText(mname);
myform.txtfatheroccupation.setText(foccupation);

//myform.txtdob.setText(month);
//myform.txtdob.setText(year);
if(gender.equals("Male"))

P a g e 102 |
{
myform.rmale.setSelected(true);
}
else
{
myform.rfemale.setSelected(true);
}
myform.cmbdate.setSelectedItem(date);
myform.cmbmonth.setSelectedItem(month);
myform.cmbyear.setSelectedItem(year);

myform.txtadmissiondate.setText(admissiondate);
myform.txtemail.setText(email);
myform.txtcontactno.setText(contactno);
myform.txtpermanentaddress.setText(paddress);

myform.txtlocaladdress.setText(laddress);
BufferedInputStream is2 = new BufferedInputStream(blob.getBinaryStream());
Image raw = ImageIO.read(is2);
ImageIcon icon = new ImageIcon(raw);
myform.spicture.setIcon(icon);

//myform.f1t2.setText(f4t2.getText());
myform.setVisible(true);

// txtroll.setText(""+rollno);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}

// TODO add your handling code here:


}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">

P a g e 103 |
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new update_student_profile().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtadmissionno;
// End of variables declaration

P a g e 104 |
}
Update Form :

Code :
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

P a g e 105 |
/**
*
* @author sand
*/
public class student_update extends javax.swing.JFrame {

/**
* Creates new form student_update
*/
String filename="";
public student_update() {
initComponents();
int i;
for(i=1;i<=31;i++)
{
cmbdate.addItem(i);

}
for(i=1900;i<=2015;i++)
{
cmbyear.addItem(i);

}
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

buttonGroup1 = new
javax.swing.ButtonGroup(); jPanel1 = new
javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
txtroll = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
P a g e 106 |
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
txtstudentname = new javax.swing.JTextField();
txtfathername = new javax.swing.JTextField();
txtmothername = new javax.swing.JTextField();
txtfatheroccupation = new javax.swing.JTextField();
rmale = new javax.swing.JRadioButton();
rfemale = new javax.swing.JRadioButton();
txtadmissiondate = new javax.swing.JTextField();
txtemail = new javax.swing.JTextField();
txtcontactno = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
txtpermanentaddress = new
javax.swing.JTextArea(); jScrollPane2 = new
javax.swing.JScrollPane(); txtlocaladdress = new
javax.swing.JTextArea(); jButton1 = new
javax.swing.JButton();
spicture = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
cmbdate = new javax.swing.JComboBox();
cmbmonth = new javax.swing.JComboBox();
cmbyear = new javax.swing.JComboBox();
txtpicturename = new
javax.swing.JTextField(); jButton3 = new
javax.swing.JButton(); cmbclass = new
javax.swing.JComboBox(); cmbsection = new
javax.swing.JComboBox();
txtadmissionno = new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N


jLabel1.setForeground(new java.awt.Color(153, 0, 0));
jLabel1.setText("Update Student Information");

jLabel2.setText("Class :");

jLabel3.setText("Section :");

jLabel4.setText("Roll No :");
P a g e 107 |
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(new
java.awt.Color(204, 204, 204), null), null), " Student Profile",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14),
new java.awt.Color(153, 0, 0))); // NOI18N

jLabel5.setText("Student Name :");

jLabel6.setText("Father's Name :");

jLabel7.setText("Mother's Name :");

jLabel8.setText("Father's Occupation :");

jLabel9.setText("Date of Birth :");

jLabel10.setText("Gender :");

jLabel11.setText("Admission date :");

jLabel12.setText("E-Mail :");

jLabel13.setText("Contact No :");

jLabel14.setText("Permanant Address :");

jLabel15.setText("Local Address :");

buttonGroup1.add(rmale);
rmale.setText("Male");

buttonGroup1.add(rfemale);
rfemale.setText("Female");

txtpermanentaddress.setColumns(20);
txtpermanentaddress.setRows(5);
jScrollPane1.setViewportView(txtpermanentaddress);

txtlocaladdress.setColumns(20);
txtlocaladdress.setRows(5);
jScrollPane2.setViewportView(txtlocaladdress);

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

P a g e 108 |
jButton1.setText("Update");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

spicture.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/profilepic.png"))); // NOI18N

jButton2.setText("Brouse");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

cmbmonth.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Month",


"Jan", "Feb", "March", "April", "May", "June", "July", "August", "September", "October",
"November", "December" }));

jButton3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jButton3.setText("Delete");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);


jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(26, 26, 26)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addComponent(jButton1)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel11)
.addComponent(jLabel9)
.addComponent(jLabel8)
.addComponent(jLabel7)

P a g e 109 |
.addComponent(jLabel6)
.addComponent(jLabel5)
.addComponent(jLabel10))
.addGap(41, 41, 41)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING, false)
.addComponent(txtadmissiondate,
javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
.addComponent(txtfathername)
.addComponent(txtmothername)
.addComponent(txtfatheroccupation)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(rmale)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.REL
ATED)
.addComponent(rfemale))
.addComponent(txtstudentname))
.addGap(72, 72, 72)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.TRAILING)
.addComponent(jLabel13)
.addComponent(jLabel12)
.addComponent(jLabel14)
.addComponent(jLabel15)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(cmbdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D)
.addComponent(cmbmonth, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D)
.addComponent(cmbyear, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(78, 78, 78)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(txtcontactno, javax.swing.GroupLayout.PREFERRED_SIZE,
166, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE, 166,
javax.swing.GroupLayout.PREFERRED_SIZE)

P a g e 110 |
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
119, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(spicture, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtpicturename))
.addGap(45, 45, 45))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(72, 72, 72)
.addComponent(jButton3)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))))
);
jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jLabel12)
.addComponent(txtstudentname,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)

P a g e 111 |
.addComponent(jLabel6)
.addComponent(jLabel13)
.addComponent(txtfathername,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtcontactno,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addComponent(jLabel7)
.addComponent(jLabel14)))
.addComponent(txtmothername,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addComponent(jLabel8)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(txtfatheroccupation,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(9, 9, 9)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout
.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(cmbdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbmonth,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbyear, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(9, 9, 9)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout
.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(rmale)
.addComponent(rfemale))))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

P a g e 112 |
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(14, 14, 14)
.addComponent(spicture, javax.swing.GroupLayout.PREFERRED_SIZE, 118,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton2)))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel11)
.addComponent(txtadmissiondate,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtpicturename,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 77,
Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton3))
.addGap(36, 36, 36))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel15)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))))
);

cmbclass.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Pre


Nurcery", "Nurcery", "L.k.G", "U.K.G", "std - 1", "std - 2", "std - 3", "std - 4 ", "std - 5", "std -
6", "std - 7", "std - 8", "std - 9", "std - 10", "std - 11", "std - +2" }));

cmbsection.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Choose


one", "section - A", "section - B", "section - C", "section - D", "section - E", "section - F",
"section - G" }));

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

P a g e 113 |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(134, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(82, 82, 82)
.addComponent(cmbclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(87, 87, 87)
.addComponent(jLabel3)
.addGap(104, 104, 104)
.addComponent(cmbsection, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(95, 95, 95)
.addComponent(jLabel4)
.addGap(58, 58, 58)
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE, 66,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(txtadmissionno, javax.swing.GroupLayout.PREFERRED_SIZE,
62, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(48, 48, 48))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(372, 372, 372))))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

P a g e 114 |
.addComponent(cmbclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbsection, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtadmissionno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(54, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 1, Short.MAX_VALUE))
);

setBounds(0, 57, 1065, 641);


}// </editor-fold>

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

Statement st1;
Connection cn1;
boolean q;

String admission,rollid,sname, fname, mname, foccupation, date,month,year, gender =


"", contactno, email, paddress, laddress, sclass, section, admissiondate,picturename;
int admissionno,rollno;

admission=txtadmissionno.getText();
admissionno =
Integer.parseInt(admission); rollid =
txtroll.getText();
P a g e 115 |
rollno = Integer.parseInt(rollid);
sclass = cmbclass.getSelectedItem().toString();
section = cmbsection.getSelectedItem().toString();
sname = txtstudentname.getText();
fname = txtfathername.getText();
mname = txtmothername.getText();
foccupation = txtfatheroccupation.getText();
date=cmbdate.getSelectedItem().toString();
month=cmbmonth.getSelectedItem().toString();
year=cmbyear.getSelectedItem().toString();
if (rmale.isSelected())
{
gender = rmale.getText();
}
else if (rfemale.isSelected()) {
gender = rfemale.getText();
}
picturename =txtpicturename.getText();
admissiondate = txtadmissiondate.getText();
contactno = txtcontactno.getText();
email = txtemail.getText();
paddress = txtpermanentaddress.getText();
laddress =txtlocaladdress.getText();

try
{
Class.forName("com.mysql.jdbc.Driver");

cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
// st1=cn1.createStatement();
if(filename.equals(""))
{

if(JOptionPane.showConfirmDialog(rootPane, "Do you want to


Save ?")==JOptionPane.YES_OPTION)
{
PreparedStatement statement = cn1.prepareStatement("UPDATE studentinfo SET
rollno = ?,class = ?,section = ?,sname = ? ,fname = ? ,mname = ?,foccupation = ?,dt = ?,month
= ?,year = ?, gender = ?,admissiondate = ?,email = ?,contactno = ?,paddress = ?,laddress = ?
WHERE admissionno = "+admissionno+""); //ps.setString(1, (String) jTable1. getValueAt(x,
0));

P a g e 116 |
statement.setInt(1,rollno);
statement.setString(2,cmbclass.getSelectedItem().toString() );
statement.setString(3,cmbsection.getSelectedItem().toString());
statement.setString(4,txtstudentname.getText());
statement.setString(5,txtfathername.getText());
statement.setString(6,txtmothername.getText());
statement.setString(7,txtfatheroccupation.getText());
statement.setString(8,cmbdate.getSelectedItem().toString());
statement.setString(9,cmbmonth.getSelectedItem().toString());
statement.setString(10,cmbyear.getSelectedItem().toString());
statement.setString(11,gender);
statement.setString(12, txtadmissiondate.getText());
statement.setString(13,txtemail.getText());
statement.setString(14,txtcontactno.getText());

statement.setString(15,txtpermanentaddress.getText());
statement.setString(16,txtlocaladdress.getText());

int row =
statement.executeUpdate(); if (row >
0)
{

JOptionPane.showMessageDialog(rootPane,"Record is Succesfully updated without


photo");
}
}
}
else
{
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to
Save ?")==JOptionPane.YES_OPTION)
{
PreparedStatement statement = cn1.prepareStatement("UPDATE studentinfo SET
rollno = ?,class = ?,section = ?,sname = ? ,fname = ? ,mname = ?,foccupation = ?,dt = ?,month
= ?,year = ?, gender = ?,admissiondate = ?,email = ?,contactno = ?,paddress = ?,laddress
= ?,photo = ? WHERE admissionno = "+admissionno+""); //ps.setString(1, (String) jTable1.
getValueAt(x, 0));

statement.setInt(1,rollno);
statement.setString(2,cmbclass.getSelectedItem().toString() );
statement.setString(3,cmbsection.getSelectedItem().toString());
statement.setString(4,txtstudentname.getText());
statement.setString(5,txtfathername.getText());
statement.setString(6,txtmothername.getText());
statement.setString(7,txtfatheroccupation.getText());
P a g e 117 |
statement.setString(8,cmbdate.getSelectedItem().toString());
statement.setString(9,cmbmonth.getSelectedItem().toString());
statement.setString(10,cmbyear.getSelectedItem().toString());
statement.setString(11,gender);
statement.setString(12, txtadmissiondate.getText());
statement.setString(13,txtemail.getText());
statement.setString(14,txtcontactno.getText());

statement.setString(15,txtpermanentaddress.getText());
statement.setString(16,txtlocaladdress.getText());
InputStream inputStream = new FileInputStream(new
File(txtpicturename.getText()));
statement.setBlob(17, inputStream);
int row = statement.executeUpdate();
if (row > 0)
{

JOptionPane.showMessageDialog(rootPane,"Record is Succesfully updated


with photo");
}
}
}
}

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

// TODO add your handling code here:


}

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


JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
File f = chooser.getSelectedFile();
filename = f.getAbsolutePath();
txtpicturename.setText(filename);
BufferedImage bi;
try
{ //display the image in jlabel
bi=ImageIO.read(f);
spicture.setIcon(new ImageIcon(bi));
}

P a g e 118 |
catch(IOException e)
{

// TODO add your handling code here:


}

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


Statement st;
Connection cn;
ResultSet rs;
String admission, sname;
int admissionno;
admission = txtadmissionno.getText();
admissionno=Integer.parseInt(admission);
sname =txtstudentname.getText();
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

st=cn.createStatement();

//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to Delete name =
"+sname)==JOptionPane.YES_OPTION)

{
String p1="delete from studentinfo where admissionno='"+admissionno+"'";

st.execute(p1);

//st1.execute(p1);

}
st.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}

P a g e 119 |
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(student_update.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(student_update.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(student_update.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(student_update.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {

P a g e 120 |
new student_update().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup
buttonGroup1; public javax.swing.JComboBox
cmbclass;
public javax.swing.JComboBox cmbdate;
public javax.swing.JComboBox cmbmonth;
public javax.swing.JComboBox
cmbsection; public
javax.swing.JComboBox cmbyear; private
javax.swing.JButton jButton1; private
javax.swing.JButton jButton2; private
javax.swing.JButton jButton3; private
javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane
jScrollPane2; public
javax.swing.JRadioButton rfemale; public
javax.swing.JRadioButton rmale; public
javax.swing.JLabel spicture;
public javax.swing.JTextField txtadmissiondate;
public javax.swing.JTextField txtadmissionno;
public javax.swing.JTextField txtcontactno;
public javax.swing.JTextField txtemail;
public javax.swing.JTextField txtfathername;
public javax.swing.JTextField txtfatheroccupation;
public javax.swing.JTextArea txtlocaladdress;
P a g e 121 |
public javax.swing.JTextField txtmothername;
public javax.swing.JTextArea
txtpermanentaddress;

P a g e 122 |
private javax.swing.JTextField txtpicturename;
public javax.swing.JTextField txtroll;
public javax.swing.JTextField txtstudentname;
// End of variables declaration
}
Delate student profile:

Code:
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates

P a g e 123 |
* and open the template in the editor.
*/

/**
*
* @author sand
*/
public class delate_student_profile extends javax.swing.JFrame {

/**
* Creates new form update_student_profile
*/
public delate_student_profile() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
txtadmissionsearch = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createEtchedBorder(new java.awt.Color(204, 204, 204), null), "Delate Student Profile :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS",
1, 14), new java.awt.Color(102, 0, 102))); // NOI18N

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel1.setText("Enter Student ID :");

txtadmissionsearch.addMouseMotionListener(new
java.awt.event.MouseMotionAdapter() {
public void mouseMoved(java.awt.event.MouseEvent evt) {

P a g e 124 |
txtadmissionsearchMouseMoved(evt);
}
});
txtadmissionsearch.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtadmissionsearchKeyReleased(evt);
}
});

jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jButton1.setText("Delete");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jButton1KeyPressed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel1)
.addGap(53, 53, 53)
.addComponent(txtadmissionsearch, javax.swing.GroupLayout.DEFAULT_SIZE, 186,
Short.MAX_VALUE)
.addGap(51, 51, 51)
.addComponent(jButton1)
.addGap(84, 84, 84))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(50, 50, 50)

P a g e 125 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(txtadmissionsearch,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addComponent(jLabel1))
.addContainerGap(57, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addGap(48, 48, 48)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(14, Short.MAX_VALUE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addGap(51, 51, 51)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(113, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

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


Statement st;
Connection cn;
ResultSet rs;
String admission, sname;
int admissionno;
admission = txtadmissionsearch.getText();
admissionno=Integer.parseInt(admission);

try
{

P a g e 126 |
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

st=cn.createStatement();

//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Are u Sure Delete This
Profile?")==JOptionPane.YES_OPTION)

{
String p1="delete from studentinfo where admissionno='"+admissionno+"'";

st.execute(p1);

//st1.execute(p1);

}
st.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
// TODO add your handling code here:
}

private void jButton1KeyPressed(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
}

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {


// TODO add your handling code here:
}

private void txtadmissionsearchKeyReleased(java.awt.event.KeyEvent evt) {


Statement st;
Connection cn;
ResultSet rs;
String admission,studentname;
int admissionno,date ,year;
admission=txtadmissionsearch.getText();
admissionno=Integer.parseInt(admission);
try

P a g e 127 |
{
Class.forName("com.mysql.jdbc.Driver");

cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from studentinfo where admissionno ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{
studentname=rs.getString("sname");

JOptionPane.showMessageDialog(null, "Do You want to Delete ,"+ studentname + "


Profile Click Delete Button");

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

// TODO add your handling code here:


}

private void txtadmissionsearchMouseMoved(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:


}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {

P a g e 128 |
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new delate_student_profile().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtadmissionsearch;
// End of variables declaration
}

P a g e 129 |
Teacher Registration form:

Code :

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

P a g e 130 |
/**
*
* @author sand
*/
public class teacher_registration extends javax.swing.JFrame {

/**
* Creates new form teacher_registration
*/
public teacher_registration() {
initComponents();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
//get current date time with Date()
Date date = new Date();
lbldate.setText(dateFormat.format(date));
Statement st;
Connection cn;
ResultSet rs;
String sql,p;
boolean q;
int addno;

sql = "select id from teacherinfo order by id desc";


try {
Class.forName("com.mysql.jdbc.Driver");
cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root",
"sandip");
st =
cn.createStatement(); rs
= st.executeQuery(sql); if
(rs.next()) {
addno =
rs.getInt("id"); addno
= addno + 1;
} else {
addno = 1;
}
lblid.setText("" + addno);
} catch (Exception e) {
JOptionPane.showMessageDialog(rootPane, e.getMessage());
}

P a g e 131 |
/**

P a g e 132 |
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

buttonGroup1 = new javax.swing.ButtonGroup();


buttonGroup2 = new
javax.swing.ButtonGroup(); jPanel1 = new
javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
txttname = new javax.swing.JTextField();
txtcontactno = new javax.swing.JTextField();
txtemailid = new javax.swing.JTextField();
txtcourse = new javax.swing.JTextField();
rmale = new javax.swing.JRadioButton();
rfemale = new javax.swing.JRadioButton();
txtexperience = new javax.swing.JTextField();
teacherpic = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
txtaddress = new javax.swing.JTextArea();
jButton3 = new javax.swing.JButton();
txtpicturename = new javax.swing.JTextField();
txtqualification = new
javax.swing.JTextField(); jLabel1 = new
javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
lblid = new javax.swing.JLabel();
jLabel13 = new
javax.swing.JLabel(); lbldate = new
javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setPreferredSize(new java.awt.Dimension(907, 520));
setResizable(false);
P a g e 133 |
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

P a g e 134 |
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel2.setText("Teacher Name :");

jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel3.setText("Contact no:");

jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel4.setText("Email id :");

jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel5.setText("course :");

jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel6.setText("Experience :");

jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel7.setText("Qualification :");

jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel8.setText("Address :");

jLabel11.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel11.setText("sex :");

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jButton1.setText("Cancel");

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jButton2.setText("Register");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

txttname.setText(" ");

txtcontactno.setText(" ");

txtemailid.setText(" ");

txtcourse.setText(" ");

buttonGroup1.add(rmale);

P a g e 135 |
rmale.setText("Male");

buttonGroup1.add(rfemale);
rfemale.setText("Female");

teacherpic.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/teacher.gif"))); // NOI18N

txtaddress.setColumns(20);
txtaddress.setRows(5);
jScrollPane1.setViewportView(txtaddress);

jButton3.setText("Brouse");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

txtpicturename.setText(" ");

txtqualification.setText(" ");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(75, 75, 75)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(jLabel11))
.addGap(57, 57, 57)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(rmale)
.addGap(36, 36, 36)

P a g e 136 |
.addComponent(rfemale))
.addComponent(txtcontactno)
.addComponent(txttname)
.addComponent(txtemailid)
.addComponent(txtcourse)
.addComponent(txtexperience)
.addComponent(txtqualification, javax.swing.GroupLayout.DEFAULT_SIZE, 195,
Short.MAX_VALUE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(teacherpic)
.addGap(72, 72, 72)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 108,
Short.MAX_VALUE)
.addComponent(txtpicturename))
.addGap(59, 59, 59))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(81, 81, 81)
.addComponent(jLabel8)
.addGap(40, 40, 40)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 115, Short.MAX_VALUE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(43, 43, 43)
.addComponent(jButton2)
.addGap(67, 67, 67))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(15, 15, 15)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)

P a g e 137 |
.addComponent(jLabel2)
.addComponent(txttname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtcontactno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtemailid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(20, 20, 20)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtcourse, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(teacherpic)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton3)
.addGap(18, 18, 18)
.addComponent(txtpicturename,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel6)
.addComponent(txtexperience, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)

P a g e 138 |
.addComponent(jLabel7)
.addComponent(txtqualification,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(rfemale)
.addComponent(rmale)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel11)
.addGap(0, 0, Short.MAX_VALUE))))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap(21, Short.MAX_VALUE))
);

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jLabel1.setForeground(new java.awt.Color(156, 0, 0));
jLabel1.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/register_pic.png"))); // NOI18N

jLabel9.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N


jLabel9.setText("Teacher id :");

lblid.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

jLabel13.setText("Date :");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addGap(52, 52, 52)

P a g e 139 |
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 615,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel9)
.addGap(40, 40, 40)
.addComponent(lblid, javax.swing.GroupLayout.PREFERRED_SIZE, 37,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel13)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
36, Short.MAX_VALUE)
.addComponent(lbldate, javax.swing.GroupLayout.PREFERRED_SIZE, 135,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30))))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(47, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel9)
.addComponent(lblid, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 15,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jLabel13)
.addComponent(lbldate, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
javax.swing.GroupLayout.PREFERRED_SIZE)))

P a g e 140 |
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 78,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(36, 36, 36))
);

setBounds(100, 65, 923, 580);


}// </editor-fold>

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

Statement st1;
Connection cn1;
boolean q;

String admission,rollid,sname, fname, mname, foccupation, date,month,year, gender =


"", contactno, email, paddress, laddress, sclass, section, admissiondate,picturename;
int id ;
id=Integer.parseInt(lblid.getText());

if (rmale.isSelected())
{
gender = rmale.getText();
}
else if (rfemale.isSelected()) {
gender = rfemale.getText();
}
try
{
Class.forName("com.mysql.jdbc.Driver");

cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st1=cn1.createStatement();
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to
Save ?")==JOptionPane.YES_OPTION)
{

String sql = "INSERT INTO teacherinfo(id, date, tname, contactno, email , course ,
experience ,qualification ,sex ,address ,photo) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

P a g e 141 |
PreparedStatement statement = cn1.prepareStatement(sql);
statement.setInt(1,id);
statement.setString(2,lbldate.getText());
statement.setString(3,txttname.getText());
statement.setString(4,txtcontactno.getText());
statement.setString(5,txtemailid.getText());
statement.setString(6,txtcourse.getText());
statement.setString(7,txtexperience.getText());
statement.setString(8,txtqualification.getText());
statement.setString(9,gender);
statement.setString(10,txtaddress.getText());

InputStream inputStream = new


FileInputStream(new File(txtpicturename.getText()));
statement.setBlob(11, inputStream);
int row =
statement.executeUpdate(); if (row >
0) {

JOptionPane.showMessageDialog(rootPane,"Record is Saved");
}
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}

// TODO add your handling code here:


}

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


JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
File f = chooser.getSelectedFile();
String filename = f.getAbsolutePath();
txtpicturename.setText(filename);

P a g e 142 |
BufferedImage bi;

P a g e 143 |
try
{ //display the image in jlabel
bi=ImageIO.read(f);
teacherpic.setIcon(new ImageIcon(bi));
}
catch(IOException e)
{

// TODO add your handling code here:


}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);

P a g e 144 |
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new teacher_registration().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup
buttonGroup2; private javax.swing.JButton
jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane
jScrollPane1; private javax.swing.JLabel
lbldate;
private javax.swing.JLabel lblid;
private javax.swing.JRadioButton rfemale;
private javax.swing.JRadioButton rmale;
private javax.swing.JLabel teacherpic;
private javax.swing.JTextArea txtaddress;
private javax.swing.JTextField txtcontactno;
private javax.swing.JTextField txtcourse;
private javax.swing.JTextField txtemailid;
private javax.swing.JTextField
txtexperience;
P a g e 145 |
private javax.swing.JTextField txtpicturename;
private javax.swing.JTextField txtqualification;

P a g e 146 |
private javax.swing.JTextField txttname;
// End of variables declaration
}
All Teacher information:

Code:

import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.table.DefaultTableModel;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/

P a g e 147 |
import java.sql.*;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class teacher_information extends javax.swing.JFrame {

/**
* Creates new form studentdetails
*/
public teacher_information() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel3 = new javax.swing.JPanel();


jPanel2 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jScrollPane2 = new
javax.swing.JScrollPane(); jTextPane1 = new
javax.swing.JTextPane(); jLabel1 = new
javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton7 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);

P a g e 148 |
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "All Records of
Teacher :", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12),
new java.awt.Color(153, 0, 0))); // NOI18N

jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {

},
new String [] {
"Teacher Id", "Name", "Contact No.", "Email", "Qualification", "Address.", "Course"
}
));
jScrollPane1.setViewportView(jTable1);

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);


jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 702,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(28, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 215,
Short.MAX_VALUE)
.addContainerGap())
);

jScrollPane2.setViewportView(jTextPane1);

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jLabel1.setText("Teacher Report Preview :");

jButton3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton3.setText("Update");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}

P a g e 149 |
});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton2.setText("Admition");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jButton6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton6.setText("Print");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});

jButton8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton8.setText("Preview");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});

jButton4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton4.setText("DELETE");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});

jButton5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton5.setText("Exit");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});

jButton1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton1.setText("Show-details ");
jButton1.addActionListener(new java.awt.event.ActionListener() {

P a g e 150 |
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inbo.png"))); //
NOI18N
jLabel3.setText(" ");

jButton7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton7.setText("Search");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);


jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(451, 451, 451)
.addComponent(jButton1))
.addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING, false)
.addComponent(jScrollPane2)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(18, 72, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)

P a g e 151 |
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(45, 45, 45))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 196,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addContainerGap(20, Short.MAX_VALUE))))
);
jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel3Layout.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(jButton3)
.addGap(27, 27, 27)
.addComponent(jButton4)
.addGap(18, 18, 18)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED
)
.addComponent(jButton7)
.addGap(13, 13, 13)
.addComponent(jButton6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED
)
.addComponent(jButton5)
.addGap(25, 25, 25)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 261,
javax.swing.GroupLayout.PREFERRED_SIZE)

P a g e 152 |
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 0,
Short.MAX_VALUE))))
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(2, 2, 2)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel1)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED
)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 219,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addComponent(jButton8)
.addContainerGap(30, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

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


DefaultTableModel model = ( DefaultTableModel)jTable1.getModel();

P a g e 153 |
Statement st1;
boolean q;
Connection cn;
ResultSet rs;
String tname,contactno,email,qualification,address,course;
int id=0;

try
{
Class.forName("com.mysql.jdbc.Driver");

cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

st1=cn.createStatement();
String p="select id,tname,contactno,email,qualification,address,course from
teacherinfo";
rs=st1.executeQuery(p);
while (rs.next())
{
id = rs.getInt("id");
tname= rs.getString("tname");
contactno= rs.getString("contactno");
email= rs.getString("email");
qualification= rs.getString("qualification");
address= rs.getString("address");
course =
rs.getString("course");
model.addRow(new
Object[]{id,tname,contactno,email,qualification,address,course});
}
//DefaultTableModel model = (DefaultTableModel) table.getModel();
st1.close();

cn.close();

}
catch(Exception e)
{
System.out.println(e.getMessage());
}

// TODO add your handling code here:


}

P a g e 154 |
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
teacher_registration myform = new teacher_registration();

P a g e 155 |
myform.setVisible(true);
// TODO add your handling code here:
}

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


if(JOptionPane.showConfirmDialog(rootPane, "Do you Want to
Exit ?")==JOptionPane.YES_OPTION)
this.dispose();
// TODO add your handling code here:
}

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


try {
if (! jTable1.print()) {
System.err.println("User cancelled printing");
}
} catch (java.awt.print.PrinterException e) {
System.err.format("Cannot print %s%n", e.getMessage());
}

// TODO add your handling code here:


}

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


{ int x=jTable1.getSelectedRow();
String d=jTable1.getValueAt(x,
0).toString(); String
n=jTable1.getValueAt(x, 1).toString();
Statement st1;
boolean q;
Connection cn;
ResultSet rs;
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

st1=cn.createStatement();

//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to Delete name =
"+n)==JOptionPane.YES_OPTION)

{
String p1="delete from teacherinfo where id='"+d+"'";

P a g e 156 |
st1.execute(p1);

//st1.execute(p1);

DefaultTableModel model = ( DefaultTableModel)jTable1.getModel();


model.removeRow(x);
}
st1.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}

// TODO add your handling code here:


}

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


int x=jTable1.getSelectedRow();

String d=jTable1.getValueAt(x,0).toString();
int id=Integer.parseInt(d);

//do the update query on this row

try {
Class.forName("com.mysql.jdbc.Driver");
if(JOptionPane.showConfirmDialog(rootPane, "Want to UPDATE id =
"+d)==JOptionPane.YES_OPTION)
{
Connection cn=
DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
PreparedStatement ps = cn.prepareStatement("UPDATE teacherinfo SET tname
= ? ,contactno = ?,email = ?,qualification = ?,address = ?,course = ? WHERE id = "+id+"");
//ps.setString(1, (String) jTable1. getValueAt(x, 0));

ps.setString(1, (String) jTable1.getValueAt(x, 1));


ps.setString(2, (String) jTable1.getValueAt(x, 2));
ps.setString(3, (String) jTable1.getValueAt(x, 3));
ps.setString(4, (String) jTable1.getValueAt(x, 4));
ps.setString(5, (String) jTable1.getValueAt(x, 5));
ps.setString(6, (String) jTable1.getValueAt(x, 6));

P a g e 157 |
ps.executeUpdate();
ps.close();
cn.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
// TODO add your handling code here:
}

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


// TODO add your handling code here:
}

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


update_teacher_form myform = new update_teacher_form();
myform.setVisible(true);
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logg
ing.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

P a g e 158 |
java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logg
ing.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logg
ing.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logg
ing.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new teacher_information().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane
jScrollPane2; private javax.swing.JTable
jTable1;
private javax.swing.JTextPane jTextPane1;
// End of variables declaration
}

P a g e 159 |
Update teacher Information :

Code:

import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
public class update_teacher_form extends javax.swing.JFrame {

/**
* Creates new form update_student_profile
*/
public update_teacher_form () {
initComponents();

P a g e 160 |
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
tid = new javax.swing.JTextField();
jButton1 = new
javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createEtchedBorder(new java.awt.Color(204, 204, 204), null), "Update Teacher Profile :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS",
1, 14), new java.awt.Color(0, 102, 102))); // NOI18N

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel1.setText("Enter Registration ID :");

jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jButton1.setText("Search");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel1)
.addGap(53, 53, 53)

P a g e 161 |
.addComponent(tid, javax.swing.GroupLayout.DEFAULT_SIZE, 186,
Short.MAX_VALUE)
.addGap(51, 51, 51)
.addComponent(jButton1)
.addGap(84, 84, 84))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(tid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addComponent(jLabel1))
.addContainerGap(57, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addGap(48, 48, 48)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addGap(51, 51, 51)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(113, Short.MAX_VALUE))
);

setBounds(100, 60, 712, 365);


}// </editor-fold>

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


Statement st;

P a g e 162 |
Connection cn;
ResultSet rs;
String
date,name,course,exeperience,qualification,sex,contactno,address,email,picturename,gen
der="";
int admissionno,id;

admissionno=Integer.parseInt(tid.getText());
try
{
Class.forName("com.mysql.jdbc.Driver");

cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from teacherinfo where id ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{

id =rs.getInt("id");
date=rs.getString("date");
name=rs.getString("tname");
contactno=rs.getString("contactno");
email=rs.getString("email");
course=rs.getString("course");
exeperience =rs.getString("experience");
qualification=rs.getString("qualification");
gender=rs.getString("sex");
address=rs.getString("address");
java.sql.Blob blob = rs.getBlob("photo");

teacher_update myform = new teacher_update();


myform.lbltid.setText(""+id);
myform.txtdate.setText(date);
myform.txttname.setText(name);
myform.txtcontactno.setText(contactno);
myform.txtemail.setText(email);
myform.txtcourse.setText(course);
myform.txtexeperience.setText(exeperience);
myform.txtqualification.setText(qualification);
if(gender.equals("Male"))
{
myform.rmale.setSelected(true);
}

P a g e 163 |
else
{
myform.rfemale.setSelected(true);
}
BufferedInputStream is2 = new BufferedInputStream(blob.getBinaryStream());
Image raw = ImageIO.read(is2);
ImageIcon icon = new ImageIcon(raw);
myform.teacherpic.setIcon(icon);

myform.txtaddress.setText(address);

myform.setVisible(true);

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

// TODO add your handling code here:


}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

P a g e 164 |
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new update_teacher_form().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField tid;
// End of variables declaration

P a g e 165 |
}

Code:
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
public class teacher_update extends javax.swing.JFrame {

P a g e 166 |
/**
* Creates new form teacher_registration
*/
String filename ="";
public teacher_update() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

buttonGroup1 = new
javax.swing.ButtonGroup(); jPanel1 = new
javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
txttname = new javax.swing.JTextField();
txtcontactno = new javax.swing.JTextField();
txtemail = new javax.swing.JTextField();
txtcourse = new javax.swing.JTextField();
rmale = new javax.swing.JRadioButton();
rfemale = new javax.swing.JRadioButton();
txtexeperience = new javax.swing.JTextField();
teacherpic = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
txtaddress = new javax.swing.JTextArea();
jButton3 = new javax.swing.JButton();
txtpicname = new javax.swing.JTextField();
txtqualification = new
javax.swing.JTextField(); jLabel1 = new
javax.swing.JLabel();
P a g e 167 |
jLabel9 = new javax.swing.JLabel();

P a g e 168 |
lbltid = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
txtdate = new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setPreferredSize(new java.awt.Dimension(907, 520));
setResizable(false);

jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel2.setText("Teacher Name :");

jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel3.setText("Contact no:");

jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel4.setText("Email id :");

jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel5.setText("course :");

jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel6.setText("Experience :");

jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel7.setText("Qualification :");

jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel8.setText("Address :");

jLabel11.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel11.setText("sex :");

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jButton1.setText("Delete");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jButton2.setText("Update");
jButton2.addActionListener(new java.awt.event.ActionListener() {

P a g e 169 |
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

txttname.setText(" ");

txtcontactno.setText(" ");

txtemail.setText(" ");

txtcourse.setText(" ");

buttonGroup1.add(rmale);
rmale.setText("Male");

buttonGroup1.add(rfemale);
rfemale.setText("Female");

teacherpic.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/teacher.gif"))); // NOI18N

txtaddress.setColumns(20);
txtaddress.setRows(5);
jScrollPane1.setViewportView(txtaddress);

jButton3.setText("Brouse");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

txtpicname.setText(" ");
txtpicname.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtpicnameActionPerformed(evt);
}
});

txtqualification.setText(" ");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

P a g e 170 |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(75, 75, 75)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(jLabel11))
.addGap(57, 57, 57)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(rmale)
.addGap(36, 36, 36)
.addComponent(rfemale))
.addComponent(txtcontactno)
.addComponent(txttname)
.addComponent(txtemail)
.addComponent(txtcourse)
.addComponent(txtexeperience)
.addComponent(txtqualification, javax.swing.GroupLayout.DEFAULT_SIZE, 195,
Short.MAX_VALUE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(teacherpic)
.addGap(72, 72, 72)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 108,
Short.MAX_VALUE)
.addComponent(txtpicname))
.addGap(59, 59, 59))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(81, 81, 81)
.addComponent(jLabel8)
.addGap(40, 40, 40)

P a g e 171 |
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 115, Short.MAX_VALUE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(43, 43, 43)
.addComponent(jButton2)
.addGap(67, 67, 67))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(15, 15, 15)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel2)
.addComponent(txttname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtcontactno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(20, 20, 20)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtcourse, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)

P a g e 172 |
.addComponent(teacherpic)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton3)
.addGap(18, 18, 18)
.addComponent(txtpicname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel6)
.addComponent(txtexeperience, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel7)
.addComponent(txtqualification,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(rfemale)
.addComponent(rmale)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel11)
.addGap(0, 0, Short.MAX_VALUE))))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap(15, Short.MAX_VALUE))
);

P a g e 173 |
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel1.setForeground(new java.awt.Color(156, 0, 0));
jLabel1.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/teacher_update_pic.png"))); // NOI18N

jLabel9.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N


jLabel9.setText("Teacher id :");

lbltid.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

jLabel13.setText("Date :");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(55, 55, 55)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 296,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL
ING
) .addComponent(jLabel9)
.addComponent(jLabel13))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI

NG) .addGroup(layout.createSequentialGroup()
.addGap(53, 53, 53)
.addComponent(lbltid, javax.swing.GroupLayout.PREFERRED_SIZE, 37,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(73, 73, 73))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtdate, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30))))

P a g e 174 |
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel9)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(lbltid, javax.swing.GroupLayout.PREFERRED_SIZE, 15,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D, 11, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel13)
.addComponent(txtdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(14, 14, 14))
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 54,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(63, 63, 63))
);

setBounds(100, 55, 923, 541);


}// </editor-fold>

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

Statement st1;
Connection cn1;
boolean q;

String tname, teachername, course,exeperience,qualification,address,foccupation,


date,month,year, gender = "", contactno, email, paddress, laddress, sclass, section,
admissiondate;

P a g e 175 |
int id,rollno;
String picturename ="";

id =
Integer.parseInt(lbltid.getText());
date= txtdate.getText();
teachername= txttname.getText();
contactno= txtcontactno.getText();
email= txtemail.getText();
course= txtcourse.getText();
exeperience= txtexeperience.getText();
qualification= txtqualification.getText();
if (rmale.isSelected())
{
gender = rmale.getText();
}
else if (rfemale.isSelected()) {
gender = rfemale.getText();
}
address= txtaddress.getText();
picturename =txtpicname.getText();

try
{
Class.forName("com.mysql.jdbc.Driver");

cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
// st1=cn1.createStatement();
if(filename.equals(""))
{

if(JOptionPane.showConfirmDialog(rootPane, "Do you want to


Save ?")==JOptionPane.YES_OPTION)
{
PreparedStatement statement = cn1.prepareStatement("UPDATE teacherinfo SET
date = ?,tname = ?,contactno = ?,email = ? ,course = ? ,experience = ?,qualification= ?,sex
= ?,address = ? WHERE id = "+id+""); //ps.setString(1, (String) jTable1. getValueAt(x, 0));

statement.setString(1,date);
statement.setString(2,teachername);

P a g e 176 |
statement.setString(3,contactno);

P a g e 177 |
statement.setString(4,email);
statement.setString(5,course);
statement.setString(6,exeperience);
statement.setString(7,qualification);
statement.setString(8,gender);
statement.setString(9,address);
int row =
statement.executeUpdate(); if (row >
0)
{

JOptionPane.showMessageDialog(rootPane,"Record is Succesfully updated without


photo");
}
}
}
else
{
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to
Save ?")==JOptionPane.YES_OPTION)
{
PreparedStatement statement = cn1.prepareStatement("UPDATE teacherinfo SET date
= ?,tname = ?,contactno = ?,email = ? ,course = ? ,experience = ?,qualification= ?,sex
= ?,address = ?,photo = ? WHERE id = "+id+""); //ps.setString(1, (String) jTable1.
getValueAt(x, 0));

statement.setString(1,date);
statement.setString(2,teachername);
statement.setString(3,contactno);
statement.setString(4,email);
statement.setString(5,course);
statement.setString(6,exeperience);
statement.setString(7,qualification);
statement.setString(8,gender);
statement.setString(9,address);
InputStream inputStream = new FileInputStream(new File(txtpicname.getText()));
statement.setBlob(10, inputStream);
int row =
statement.executeUpdate(); if (row >
0)
{

JOptionPane.showMessageDialog(rootPane,"Record is Succesfully updated


with photo");
}
P a g e 178 |
}

P a g e 179 |
}
}

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

// TODO add your handling code here:


}

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


// TODO add your handling code here:
}

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


JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
File f = chooser.getSelectedFile();
filename = f.getAbsolutePath();
txtpicname.setText(filename);
BufferedImage bi;
try
{ //display the image in jlabel
bi=ImageIO.read(f);
teacherpic.setIcon(new ImageIcon(bi));
}
catch(IOException e)
{

}
// TODO add your handling code here:
}

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


Statement st;
Connection cn;
ResultSet rs;
String admission, sname;
int id;
admission = lbltid.getText();
id=Integer.parseInt(admission);
sname =txttname.getText();
try
{

P a g e 180 |
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

st=cn.createStatement();

//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to Delete name =
"+sname)==JOptionPane.YES_OPTION)

{
String p1="delete from teacherinfo where id='"+id+"'";

st.execute(p1);

//st1.execute(p1);

}
st.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;

P a g e 181 |
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new teacher_update().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup
buttonGroup1; private javax.swing.JButton
jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
P a g e 182 |
private javax.swing.JScrollPane
jScrollPane1; public javax.swing.JLabel
lbltid;
public javax.swing.JRadioButton rfemale;
public javax.swing.JRadioButton rmale;
public javax.swing.JLabel teacherpic;
public javax.swing.JTextArea txtaddress;
public javax.swing.JTextField
txtcontactno; public
javax.swing.JTextField txtcourse; public
javax.swing.JTextField txtdate; public
javax.swing.JTextField txtemail;
public javax.swing.JTextField txtexeperience;
private javax.swing.JTextField txtpicname;
public javax.swing.JTextField txtqualification;
public javax.swing.JTextField txttname;
// End of variables declaration
}
Delete teacher Profile :

Code:
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

P a g e 183 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
public class delate_teacher_profile extends javax.swing.JFrame {

/**
* Creates new form update_student_profile
*/
public delate_teacher_profile() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
txtadmissionsearch = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createEtchedBorder(new java.awt.Color(204, 204, 204), null), "Delate Teacher Profile :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS",
1, 14), new java.awt.Color(0, 102, 102))); // NOI18N

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel1.setText("Enter Teacher ID :");

P a g e 184 |
txtadmissionsearch.addMouseMotionListener(new
java.awt.event.MouseMotionAdapter() {
public void mouseMoved(java.awt.event.MouseEvent evt) {
txtadmissionsearchMouseMoved(evt);
}
});
txtadmissionsearch.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtadmissionsearchKeyReleased(evt);
}
});

jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jButton1.setText("Delete");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jButton1KeyPressed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel1)
.addGap(53, 53, 53)
.addComponent(txtadmissionsearch, javax.swing.GroupLayout.DEFAULT_SIZE, 186,
Short.MAX_VALUE)
.addGap(51, 51, 51)
.addComponent(jButton1)
.addGap(84, 84, 84))
);
jPanel1Layout.setVerticalGroup(

P a g e 185 |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(txtadmissionsearch,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addComponent(jLabel1))
.addContainerGap(57, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addGap(48, 48, 48)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addGap(51, 51, 51)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(113, Short.MAX_VALUE))
);

setBounds(100, 55, 689, 365);


}// </editor-fold>

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


Statement st;
Connection cn;
ResultSet rs;
String admission, sname;
int admissionno;
admission = txtadmissionsearch.getText();
admissionno=Integer.parseInt(admission);

P a g e 186 |
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

st=cn.createStatement();

//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Are u Sure Delete This
Profile?")==JOptionPane.YES_OPTION)

{
String p1="delete from teacherinfo where id='"+admissionno+"'";

st.execute(p1);

//st1.execute(p1);

}
st.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
// TODO add your handling code here:
}

private void jButton1KeyPressed(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
}

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {


// TODO add your handling code here:
}

private void txtadmissionsearchKeyReleased(java.awt.event.KeyEvent evt) {


Statement st;
Connection cn;
ResultSet rs;
String admission,teachername;
int admissionno,date ,year;

P a g e 187 |
admission=txtadmissionsearch.getText();
admissionno=Integer.parseInt(admission);
try
{
Class.forName("com.mysql.jdbc.Driver");

cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from teacherinfo where id ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{
teachername=rs.getString("tname");

JOptionPane.showMessageDialog(null, "Do You want to Delete ,"+ teachername + "


Profile Click Delete Button");

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

// TODO add your handling code here:


}

private void txtadmissionsearchMouseMoved(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:


}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {

P a g e 188 |
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new delate_teacher_profile().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtadmissionsearch;
// End of variables declaration
}

P a g e 189 |
Insert Fees Structure : (add_fees_structure.java)

Code:
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**

P a g e 190 |
*
* @author sand
*/
public class add_fees_structure extends javax.swing.JFrame {

/**
* Creates new form add_fees_structure
*/
public add_fees_structure() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
pcharge = new javax.swing.JTextField();
rcharge = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
acharge = new javax.swing.JTextField();
dcharge = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
tcharge = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
scharge = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
lcharge = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
ucharge = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
bcharge = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
mcharge = new javax.swing.JTextField();
lbltotal = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();

P a g e 191 |
cmbclass = new javax.swing.JComboBox();
jButton2 = new javax.swing.JButton();
jLabel11 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jLabel1.setText("Prospectus charge :");

jLabel2.setText("Registration charge :");

jButton1.setText("Total");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jLabel3.setText("Admission charge :");

jLabel4.setText("Development charge :");

jLabel5.setText("Tution Fees :");

jLabel6.setText("Sports :");

jLabel7.setText("Library Fees :");

jLabel8.setText("Uniform Fees :");

jLabel9.setText("Book Fees :");

jLabel10.setText("Misslaneous Fees :");

lbltotal.setText("=");

jLabel12.setText("Class :");

cmbclass.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Pre


Nurcery", "Nurcery", "L.k.G", "U.K.G", "std - 1", "std - 2", "std - 3", "std - 4 ", "std - 5", "std -
6", "std - 7", "std - 8", "std - 9", "std - 10", "std - 11", "std - +2" }));

jButton2.setText("Submit");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);

P a g e 192 |
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(93, 93, 93)
.addComponent(jButton1)
.addGap(75, 75, 75))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.TRAILING)
.addComponent(jLabel2)
.addComponent(jLabel1)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5))
.addGap(66, 66, 66)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(lbltotal, javax.swing.GroupLayout.PREFERRED_SIZE, 83,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.LEADING)
.addComponent(rcharge, javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pcharge, javax.swing.GroupLayout.PREFERRED_SIZE, 72,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(acharge, javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(dcharge, javax.swing.GroupLayout.PREFERRED_SIZE, 73,
javax.swing.GroupLayout.PREFERRED_SIZE)

P a g e 193 |
.addComponent(tcharge, javax.swing.GroupLayout.PREFERRED_SIZE, 73,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2)
.addGap(37, 37, 37))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(127, 127, 127)
.addComponent(jLabel12)
.addGap(56, 56, 56)
.addComponent(cmbclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel7)
.addComponent(jLabel6)
.addComponent(jLabel8)
.addComponent(jLabel9)
.addComponent(jLabel10))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
68, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(lcharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 56,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(scharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 56,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(ucharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 56,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bcharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 56,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(mcharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 56,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(48, 48, 48))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()

P a g e 194 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel12)
.addComponent(jLabel6)
.addComponent(scharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(12, 12, 12)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel1)
.addComponent(pcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)
.addComponent(lcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(rcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8)
.addComponent(ucharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel2))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel9))
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED
)
.addComponent(acharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel3))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(bcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

P a g e 195 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(dcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(jLabel10))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(tcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
28, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lbltotal, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(24, 24, 24))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(mcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2)
.addGap(32, 32, 32))))
);

jLabel11.setText("INSERT FEES STRUCTURE :");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addGap(235, 235, 235)
.addComponent(jLabel11)
.addContainerGap())

P a g e 196 |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(0, 20, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel11)
.addGap(18, 18, 18)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

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


int pros,reg,add,dev,tut,sports,library,uni,book,miss,total;
pros=Integer.parseInt(pcharge.getText());
reg=Integer.parseInt(rcharge.getText());
add=Integer.parseInt(acharge.getText());
dev=Integer.parseInt(dcharge.getText());
tut=Integer.parseInt(tcharge.getText());
sports=Integer.parseInt(scharge.getText());
library=Integer.parseInt(lcharge.getText());
uni=Integer.parseInt(ucharge.getText());
book=Integer.parseInt(bcharge.getText());
miss=Integer.parseInt(mcharge.getText());
total=pros+reg+add+dev+tut+sports+library+uni+book+miss;
lbltotal.setText(""+total);
// TODO add your handling code here:
}

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

Statement st1;
Connection cn1;
boolean q;
String sclass;
int pros,reg,add,dev,tut,sports,library,uni,book,miss,total;
sclass = cmbclass.getSelectedItem().toString();
pros=Integer.parseInt(pcharge.getText());

P a g e 197 |
reg=Integer.parseInt(rcharge.getText());
add=Integer.parseInt(acharge.getText());
dev=Integer.parseInt(dcharge.getText());
tut=Integer.parseInt(tcharge.getText());
sports=Integer.parseInt(scharge.getText());
library=Integer.parseInt(lcharge.getText());
uni=Integer.parseInt(ucharge.getText());
book=Integer.parseInt(bcharge.getText());
miss=Integer.parseInt(mcharge.getText());
total=Integer.parseInt(lbltotal.getText());
try
{
Class.forName("com.mysql.jdbc.Driver");

cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st1=cn1.createStatement();
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to
Save ?")==JOptionPane.YES_OPTION)
{
String sql = "INSERT INTO fees (class, prospectus, registration , addmission ,
development , tution ,sports ,library,uniform,book,misllaneous ,total) values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

PreparedStatement statement = cn1.prepareStatement(sql);


statement.setString(1,cmbclass.getSelectedItem().toString() );
statement.setInt(2,pros);
statement.setInt(3,reg);
statement.setInt(4,add);
statement.setInt(5,dev);
statement.setInt(6,tut);
statement.setInt(7,sports);
statement.setInt(8,library);
statement.setInt(9,uni);
statement.setInt(10,book);
statement.setInt(11,miss);
statement.setInt(12,total);

int row =
statement.executeUpdate(); if (row >
0) {

P a g e 198 |
JOptionPane.showMessageDialog(rootPane,"Record is Saved");
}
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(add_fees_structure.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(add_fees_structure.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(add_fees_structure.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

P a g e 199 |
java.util.logging.Logger.getLogger(add_fees_structure.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new add_fees_structure().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField acharge;
private javax.swing.JTextField bcharge;
private javax.swing.JComboBox cmbclass;
private javax.swing.JTextField dcharge;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lbltotal;
private javax.swing.JTextField lcharge;
private javax.swing.JTextField mcharge;
private javax.swing.JTextField pcharge;
private javax.swing.JTextField rcharge;
private javax.swing.JTextField scharge;
private javax.swing.JTextField tcharge;
private javax.swing.JTextField ucharge;
// End of variables declaration
}

P a g e 200 |
Take Admission Fees(add_fees.java)

Code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
public class add_fees extends javax.swing.JFrame {

/**
* Creates new form add_fees
*/
public add_fees() {

P a g e 201 |
initComponents();
Statement st;
Connection cn;
ResultSet rs;
String sql;

int invc;

sql = "select invoice from addfees order by invoice desc";


try
{
Class.forName("com.mysql.jdbc.Driver");

cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
rs=st.executeQuery(sql);
if(rs.next())
{
invc=rs.getInt("invoice");
invc=invc+1;
}
else
{
invc=1;
}
lblinvoice.setText(""+invc);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();

P a g e 202 |
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
txtaddno = new javax.swing.JTextField();
txtclass = new javax.swing.JTextField();
txtsname = new javax.swing.JTextField();
txtroll = new javax.swing.JTextField();
txtsection = new javax.swing.JTextField();
txtfname = new javax.swing.JTextField();
txtdate = new javax.swing.JTextField();
lblinvoice = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jLabel11 = new javax.swing.JLabel();
pcharge = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
scharge = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
rcharge = new javax.swing.JLabel();
acharge = new javax.swing.JLabel();
dcharge = new javax.swing.JLabel();
tcharge = new javax.swing.JLabel();
jLabel23 = new javax.swing.JLabel();
jLabel24 = new javax.swing.JLabel();
jLabel25 = new javax.swing.JLabel();
jLabel26 = new javax.swing.JLabel();
lcharge = new javax.swing.JLabel();
ucharge = new javax.swing.JLabel();
bcharge = new javax.swing.JLabel();
mcharge = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
lbltotal = new javax.swing.JLabel();
jButton4 = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

P a g e 203 |
jLabel1.setText("Admission no :");

jLabel2.setText("Class :");

jLabel3.setText("Student Name :");

jLabel4.setText("Invoice no :");

jLabel5.setText("Rool No :");

jLabel6.setText("Section :");

jLabel7.setText("Fathers' Name :");

jLabel8.setText("Date :");

txtsname.setText(" ");

txtroll.setText(" ");

lblinvoice.setText(" ");

jButton1.setText("Show");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING)
.addComponent(jLabel2)
.addComponent(jLabel1))
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING))
.addGap(75, 75, 75)

P a g e 204 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING, false)
.addComponent(lblinvoice, javax.swing.GroupLayout.PREFERRED_SIZE, 59,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtclass)
.addComponent(txtaddno)
.addComponent(txtsname, javax.swing.GroupLayout.DEFAULT_SIZE, 99,
Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 73,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel8)
.addComponent(jLabel7))
.addGap(2, 2, 2)))
.addGap(32, 32, 32)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(48, 48, 48)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(txtsection, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton1)))
.addGap(25, 25, 25))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtdate, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()

P a g e 205 |
.addComponent(txtfname, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(102, 102, 102)))))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel1)
.addComponent(jLabel5)
.addComponent(txtaddno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addGap(19, 19, 19)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel2)
.addComponent(jLabel6)
.addComponent(txtclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtsection, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel3)
.addComponent(jLabel7)
.addComponent(txtsname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtfname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel4)
.addComponent(jLabel8)
.addComponent(txtdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblinvoice))
.addContainerGap(33, Short.MAX_VALUE))
);

P a g e 206 |
jLabel11.setText("Prospectus Charge :");

jLabel13.setText("Sports Fee :");

jLabel15.setText("Registration Charge :");

jLabel16.setText("Admission Charge :");

jLabel17.setText("Development Charge :");

jLabel18.setText("Tution fee :");

jLabel23.setText("Library fee :");

jLabel24.setText("Uniform Fee :");

jLabel25.setText("Book Charge :");

jLabel26.setText("Misllaneous Charge :");

ucharge.setText(" ");

bcharge.setText(" ");

mcharge.setText(" ");

jButton2.setText("Show Fees Charge :");


jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jButton3.setText("Total :");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jButton4.setText("Submit");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);

P a g e 207 |
}
});

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);


jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel18)
.addComponent(jLabel17)
.addComponent(jLabel16)
.addComponent(jLabel15)
.addComponent(jLabel11)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton3)))
.addGap(55, 55, 55)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING, false)
.addComponent(rcharge, javax.swing.GroupLayout.DEFAULT_SIZE, 80,
Short.MAX_VALUE)
.addComponent(acharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(dcharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pcharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(tcharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lbltotal, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(85, 85, 85)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel13)

P a g e 208 |
.addComponent(jLabel25)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.TRAILING)
.addComponent(jLabel23)
.addComponent(jLabel24))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel26)))
.addGap(83, 83, 83)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addComponent(scharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELA
TED)
.addComponent(jButton2))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addComponent(jButton4)
.addGap(118, 118, 118))))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(bcharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lcharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(ucharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(mcharge, javax.swing.GroupLayout.DEFAULT_SIZE, 44,
Short.MAX_VALUE))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()

P a g e 209 |
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel11)
.addComponent(pcharge, javax.swing.GroupLayout.PREFERRED_SIZE, 14,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13)
.addComponent(jButton2)
.addComponent(scharge, javax.swing.GroupLayout.PREFERRED_SIZE, 12,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(rcharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(jLabel15)
.addComponent(jLabel23))
.addComponent(lcharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(acharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 14,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(jLabel16)
.addComponent(jLabel24)
.addComponent(ucharge)))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(dcharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(jLabel17)
.addComponent(jLabel25)
.addComponent(bcharge)))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)

P a g e 210 |
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(jLabel18)
.addComponent(mcharge)
.addComponent(jLabel26))
.addComponent(tcharge, javax.swing.GroupLayout.PREFERRED_SIZE, 17,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(lbltotal, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(jButton3)
.addComponent(jButton4)))
.addContainerGap())
);

jLabel10.setText("Admission fees details :");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(layout.createSequentialGroup()
.addGap(340, 340, 340)
.addComponent(jLabel10))
.addGroup(layout.createSequentialGroup()
.addGap(66, 66, 66)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel10)

P a g e 211 |
.addGap(18, 18, 18)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25,
Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);

pack();
}// </editor-fold>

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


int addno,roll;
addno=Integer.parseInt(txtaddno.getText());

Connection cn;
Statement st;
ResultSet rs;
String name,fname,sclass,section;

try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();

String sql="select rollno,sname,fname,class,section from studentinfo where


admissionno ="+addno+"";
rs=st.executeQuery(sql);
if(rs.next())
{
roll=rs.getInt("rollno");
name=rs.getString("sname");
fname=rs.getString("fname");
sclass=rs.getString("class");
section=rs.getString("section");

txtroll.setText(""+roll);
txtsname.setText(name);
txtfname.setText(fname);
txtclass.setText(sclass);

P a g e 212 |
txtsection.setText(section);

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

DateFormat dateFormat=new SimpleDateFormat("dd/MM/yyyy");


java.util.Date date = new java.util.Date();
txtdate.setText(dateFormat.format(date));

// TODO add your handling code here:


}

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


int pros,reg,add,dev,tution,sport,lib,uniform,book,miss,total;
Connection cn;
Statement st;
ResultSet rs;

String sclass,sql;
sclass=txtclass.getText();

try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();

sql="select
prospectus,registration,addmission,development,tution,sports,library,uniform,book,misll
aneous,total from fees where class ='"+sclass+"'";
rs=st.executeQuery(sql);
//JOptionPane.showConfirmDialog(rootPane,sclass);
if(rs.next())
{
pros=rs.getInt("prospectus");
reg=rs.getInt("registration");
add=rs.getInt("addmission");
dev=rs.getInt("development");

P a g e 213 |
tution=rs.getInt("tution");
sport=rs.getInt("sports");
lib=rs.getInt("library");
uniform=rs.getInt("uniform");
book=rs.getInt("book");
miss=rs.getInt("misllaneous");
total=rs.getInt("total");

pcharge.setText(""+pros);
rcharge.setText(""+reg);
acharge.setText(""+add);
dcharge.setText(""+dev);
tcharge.setText(""+tution);
scharge.setText(""+pros);
lcharge.setText(""+lib);
ucharge.setText(""+uniform);
bcharge.setText(""+book);
mcharge.setText(""+pros);
lbltotal.setText(""+total);

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

// TODO add your handling code here:


}

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


int addno,roll,invc,pros,sport,reg,lib,adms,uniform,dev,book,tution,miss,total;
String sclass,section,sname,fname,adate,sql;

Connection cn;
Statement st;
ResultSet rs;

adate=txtdate.getText();
invc=Integer.parseInt(lblinvoice.getText());
addno=Integer.parseInt(txtaddno.getText());

P a g e 214 |
roll=Integer.parseInt(txtroll.getText());
sclass=txtclass.getText();
section=txtsection.getText();
sname=txtsname.getText();
fname=txtfname.getText();
pros=Integer.parseInt(pcharge.getText());
reg=Integer.parseInt(rcharge.getText());
adms=Integer.parseInt(acharge.getText());
dev=Integer.parseInt(dcharge.getText());
tution=Integer.parseInt(tcharge.getText());
sport=Integer.parseInt(scharge.getText());
lib=Integer.parseInt(lcharge.getText());
uniform=Integer.parseInt(ucharge.getText());
book=Integer.parseInt(bcharge.getText());
miss=Integer.parseInt(mcharge.getText());
total=Integer.parseInt(lbltotal.getText());
try
{
Class.forName("com.mysql.jdbc.Driver");

cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
int adno;
String p="select addmission_no from addfees where addmission_no="+addno+"";
rs=st.executeQuery(p);
if(rs.next())
{
JOptionPane.showMessageDialog(rootPane,"Addmission already ");

}
else
{
sql="insert into
addfees(bdate,invoice,addmission_no,roll,class,section,name,fname,prospectus,registrati
on,admission,development,tution,sport,library,uniform,book,misslaneous,total)
values('"+adate+"',"+invc+","+addno+","+roll+",'"+sclass+"','"+section+"','"+sname+"','"+fname+
"',"+pros+","+reg+","+adms+","+dev+","+tution+","+sport+","+lib+","+uniform+","+book+","+mi
ss+","+total+")";
st.execute(sql);

JOptionPane.showMessageDialog(rootPane,"Record is saved");
}
}
catch(Exception e)
{

P a g e 215 |
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}

// TODO add your handling code here:


}

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


// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(add_fees.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(add_fees.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(add_fees.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(add_fees.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);

P a g e 216 |
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new add_fees().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel acharge;
private javax.swing.JLabel bcharge;
private javax.swing.JLabel dcharge;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JLabel lblinvoice;
private javax.swing.JLabel lbltotal;
private javax.swing.JLabel lcharge;
private javax.swing.JLabel mcharge;
private javax.swing.JLabel pcharge;
private javax.swing.JLabel rcharge;

P a g e 217 |
private javax.swing.JLabel scharge;
private javax.swing.JLabel tcharge;
private javax.swing.JTextField txtaddno;
private javax.swing.JTextField txtclass;
private javax.swing.JTextField txtdate;
private javax.swing.JTextField txtfname;
private javax.swing.JTextField txtroll;
private javax.swing.JTextField txtsection;
private javax.swing.JTextField txtsname;
private javax.swing.JLabel ucharge;
// End of variables declaration
}
Take Monthly Fees: (Monthly_fees.java)

Code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

P a g e 218 |
/**
*
* @author sand
*/
public class monthly_fees extends javax.swing.JFrame {

/**
* Creates new form monthly_fees
*/
public monthly_fees() {
initComponents();
cmbfrom.addItem("January");
cmbfrom.addItem("February");
cmbfrom.addItem("March");
cmbfrom.addItem("April");
cmbfrom.addItem("May");
cmbfrom.addItem("June");
cmbfrom.addItem("July");
cmbfrom.addItem("August");
cmbfrom.addItem("September");
cmbfrom.addItem("October");
cmbfrom.addItem("November");
cmbfrom.addItem("December");

cmbto.addItem("January");
cmbto.addItem("February");
cmbto.addItem("March");
cmbto.addItem("April");
cmbto.addItem("May");
cmbto.addItem("June");
cmbto.addItem("July");
cmbto.addItem("August");
cmbto.addItem("September");
cmbto.addItem("October");
cmbto.addItem("November");
cmbto.addItem("December");

Statement st;
Connection cn;
ResultSet rs;
String sql,p;
boolean q;

P a g e 219 |
int receipt;
// sql = "select max(student_add.admission_no) from student_add";
sql = "select receipt from transaction order by receipt desc";
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
rs=st.executeQuery(sql);
if(rs.next())
{
receipt =rs.getInt("receipt");
receipt=receipt+1;
}
else
{
receipt=1;
}
lblreceipt.setText(""+receipt);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new
javax.swing.JLabel(); jLabel7 = new
javax.swing.JLabel(); jLabel8 =
new javax.swing.JLabel(); jLabel9
= new javax.swing.JLabel();
P a g e 220 |
txtaddno = new javax.swing.JTextField();
txtclass = new javax.swing.JTextField();
txtsname = new javax.swing.JTextField();
txtroll = new javax.swing.JTextField();
txtsection = new javax.swing.JTextField();
txtfname = new javax.swing.JTextField();
txtdate = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
cmbfrom = new javax.swing.JComboBox();
cmbto = new javax.swing.JComboBox();
jLabel11 = new javax.swing.JLabel();
lbltotal = new javax.swing.JLabel();
lblttl = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
lblreceipt = new javax.swing.JLabel();
lblinvoice = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jLabel2.setText("Addmission No :");

jLabel3.setText("Class :");

jLabel4.setText("Student Name :");

jLabel5.setText("Reciept No :");

jLabel6.setText("Roll No :");

jLabel7.setText("Section :");

jLabel8.setText("Fathers Name :");

jLabel9.setText("Date :");

jLabel10.setText("Monthly Fees :");

cmbfrom.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "From" }));


cmbfrom.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmbfromActionPerformed(evt);
}
});

P a g e 221 |
cmbto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "to" }));
cmbto.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmbtoActionPerformed(evt);
}
});

jLabel11.setText("Total Fees :");

lblttl.setText(" ");

jButton1.setText("Save");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setText("SHOW");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

lblinvoice.setText(" ");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(65, 65, 65)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL
ING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.T
RAILING)
.addComponent(jLabel5)
.addComponent(jLabel4)
.addComponent(jLabel3)
.addComponent(jLabel2))
.addGroup(jPanel1Layout.createSequentialGroup()

P a g e 222 |
.addGap(14, 14, 14)
.addComponent(jLabel11)))
.addComponent(jLabel10))
.addGap(70, 70, 70)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG
) .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(lbltotal, javax.swing.GroupLayout.PREFERRED_SIZE, 63,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.TRAILING, false)
.addComponent(txtclass, javax.swing.GroupLayout.DEFAULT_SIZE, 59,
Short.MAX_VALUE)
.addComponent(txtsname)
.addComponent(txtaddno)
.addComponent(lblreceipt, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(cmbfrom, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(lblttl, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(cmbto, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(43, 43, 43))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(131, 131, 131)

P a g e 223 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING, false)
.addComponent(lblinvoice, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING))))
.addGap(81, 81, 81)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addComponent(txtsection)
.addComponent(txtfname)
.addComponent(txtdate)
.addComponent(jButton1)
.addComponent(txtroll))
.addContainerGap(157, Short.MAX_VALUE))))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel2)
.addComponent(jLabel6)
.addComponent(txtaddno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel3)
.addComponent(jLabel7)
.addComponent(txtclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtsection, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)

P a g e 224 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel4)
.addComponent(jLabel8)
.addComponent(txtsname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtfname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(25, 25, 25)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jLabel9)
.addComponent(txtdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblinvoice))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblreceipt, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jLabel10)
.addComponent(cmbfrom, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(cmbto, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG
) .addGroup(jPanel1Layout.createSequentialGroup()
.addGap(32, 32, 32)

P a g e 225 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel11)
.addComponent(lbltotal, javax.swing.GroupLayout.PREFERRED_SIZE, 14,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(lblttl)))
.addGap(18, 24, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(37, 37, 37))
);

jLabel1.setText("MONTHLY FEES DETAILS :");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(299, 299, 299)
.addComponent(jLabel1)
.addContainerGap(351, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(28, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

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

int addno,roll;

P a g e 226 |
addno=Integer.parseInt(txtaddno.getText());

Connection cn;
Statement st;
ResultSet rs;

String name,fname,sclass,section,mfrom,mto;
int feesfrom=1;
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();

String sql="select rollno,sname,fname,class,section from studentinfo where admissionno


="+addno+"";
rs=st.executeQuery(sql);
if(rs.next())
{
roll=rs.getInt("rollno");
name=rs.getString("sname");
fname=rs.getString("fname");
sclass=rs.getString("class");
section=rs.getString("section");

txtroll.setText(""+roll);
txtsname.setText(name);
txtfname.setText(fname);
txtclass.setText(sclass);
txtsection.setText(section);

}
cn.close();
st.close();
rs.close();

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

try

P a g e 227 |
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();
String sql="select feesto from transaction where addmission_no="+addno+" order by feesto
desc";
rs=st.executeQuery(sql);
if(rs.next())
{

mto=rs.getString("feesto");

cmbto.setSelectedItem(mto);
feesfrom=feesfrom+ cmbto.getSelectedIndex();
cmbfrom.setSelectedIndex(feesfrom);
int feesto=feesfrom;
cmbto.setSelectedIndex(feesto);

}
else
{
JOptionPane.showMessageDialog(rootPane,"You submit first time fees in the year");
cmbfrom.setSelectedIndex(4);
cmbto.setSelectedIndex(4);
}
cn.close();
st.close();
rs.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}

DateFormat dateFormat=new SimpleDateFormat("dd/MM/yyyy");


java.util.Date date = new java.util.Date();
txtdate.setText(dateFormat.format(date));

// TODO add your handling code here:


}

P a g e 228 |
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Connection cn;
Statement st;

int addno,roll,receipt,total;
String sclass,section,name,fname,recdate,ffrom,fto;

try
{

Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");

st=cn.createStatement();
addno=Integer.parseInt(txtaddno.getText());
roll=Integer.parseInt(txtroll.getText());
sclass=txtclass.getText();
section=txtsection.getText();
name=txtsname.getText();
fname=txtfname.getText();
receipt=Integer.parseInt(lblreceipt.getText());
recdate=txtdate.getText();
ffrom=cmbfrom.getSelectedItem().toString();
fto=cmbto.getSelectedItem().toString();
total=Integer.parseInt(lblttl.getText());

JOptionPane.showMessageDialog(rootPane,"Connection Rerady");

String sql="insert into transaction


values("+addno+","+roll+",'"+sclass+"','"+section+"','"+name+"','"+fname+"',"+receipt+",'"+recdate+"','
"+ffrom+"','"+fto+"',"+total+")";
boolean q= st.execute(sql);
JOptionPane.showMessageDialog(rootPane,"Fees record is saved");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}

// TODO add your handling code here:


}

P a g e 229 |
private void cmbtoActionPerformed(java.awt.event.ActionEvent evt) {
int from,to=1,total=1,tt;

from
=cmbfrom.getSelectedIndex(); to =
to+cmbto.getSelectedIndex();
tt=to-from;
total=(1500*tt);
lbltotal.setText("1500 * "+tt+" = ");
lblttl.setText(""+total);
// TODO add your handling code here:
}

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


int from,to=1,total=1,tt;

from
=cmbfrom.getSelectedIndex(); to =
to+cmbto.getSelectedIndex();
tt=to-from;
total=(1500*tt);
lbltotal.setText("1500 * "+tt+" = ");
lblttl.setText(""+total);
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(monthly_fees.class.getName()).log(java.util.logging.Level.SEVER
P a g e 230 |
E, null, ex);

P a g e 231 |
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(monthly_fees.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(monthly_fees.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(monthly_fees.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable()
{
public void run() {
new monthly_fees().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JComboBox cmbfrom;
private javax.swing.JComboBox cmbto;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lblinvoice;
private javax.swing.JLabel lblreceipt;
private javax.swing.JLabel lbltotal;
private javax.swing.JLabel lblttl;
private javax.swing.JTextField txtaddno;
private javax.swing.JTextField txtclass;
P a g e 232 |
private javax.swing.JTextField txtdate;
private javax.swing.JTextField txtfname;
private javax.swing.JTextField txtroll;
private javax.swing.JTextField txtsection;
private javax.swing.JTextField txtsname;
// End of variables declaration
}
Mail form(send_mail.java)

Code:
import java.net.PasswordAuthentication;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**

P a g e 233 |
*
* @author sand
*/
public class send_mail extends javax.swing.JFrame {

/**
* Creates new form send_mail
*/
public send_mail() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
txtemail = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
txtmassage = new javax.swing.JTextArea();
jLabel4 = new javax.swing.JLabel();
txtadmissionno = new
javax.swing.JTextField(); jButton1 = new
javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jLabel1.setText("Enter Reciept Email Id :");

jLabel2.setText("Message :");

txtmassage.setColumns(20);
txtmassage.setRows(5);
jScrollPane1.setViewportView(txtmassage);

jLabel4.setText("Enter Student Admission no :");

txtadmissionno.addKeyListener(new java.awt.event.KeyAdapter() {
P a g e 234 |
public void keyReleased(java.awt.event.KeyEvent evt) {
txtadmissionnoKeyReleased(evt);
}
});

jButton1.setText("Send");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(53, 53, 53)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL
ING
) .addComponent(jLabel2)
.addComponent(jLabel1)
.addComponent(jLabel4))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI

NG) .addComponent(jButton1)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE, 136,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtadmissionno, javax.swing.GroupLayout.PREFERRED_SIZE, 136,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(82, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(26, 26, 26)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel4)
.addComponent(txtadmissionno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

P a g e 235 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel1)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(18, 18, 18)
.addComponent(jButton1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

jLabel3.setText("Fees Report Sender Mail Form :");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(169, 169, 169)
.addComponent(jLabel3)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 42, Short.MAX_VALUE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(37, Short.MAX_VALUE))
);

setBounds(100, 50, 516, 339);


}// </editor-fold>

P a g e 236 |
private void txtadmissionnoKeyReleased(java.awt.event.KeyEvent evt) {
int addno,roll;
addno=Integer.parseInt(txtadmissionno.getText());

Connection cn;
Statement st;
ResultSet rs;
String name,fname,sclass,section;

try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();

String sql="select rollno,sname from studentinfo where admissionno ="+addno+"";


rs=st.executeQuery(sql);
if(rs.next())
{
roll=rs.getInt("rollno");
name=rs.getString("sname");

// txtroll.setText(""+roll);
txtmassage.setText("student name :"+name+roll);
//txtfname.setText(fname);
//txtclass.setText(sclass);
// txtsection.setText(section);

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

// TODO add your handling code here:


}

P a g e 237 |
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String email = "",msg;
msg=txtmassage.getText();
email=txtemail.getText();
String to="[email protected]";//change accordingly
{
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");

Session session =
Session.getDefaultInstance(props, new
javax.mail.Authenticator() {
// protected PasswordAuthentication getPasswordAuthentication()
{
// return new PasswordAuthentication("[email protected]","chikku@gmail");//
change accordingly
}
});
//compose message
try {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("[email protected]"));//change accordingly
message.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
message.setSubject("Hello");
message.setText(msg);

//send message
Transport.send(message);

JOptionPane.showMessageDialog(rootPane, "Email send successfully");

} catch (MessagingException e) {
JOptionPane.showMessageDialog(rootPane, e.getMessage());
//throw new RuntimeException(e);
}

}
// TODO add your handling code here:
}

P a g e 238 |
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(send_mail.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(send_mail.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(send_mail.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(send_mail.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable()
{
public void run() {
new send_mail().setVisible(true);
}
});
}

P a g e 239 |
// Variables declaration - do not modify

P a g e 240 |
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField
txtadmissionno; private
javax.swing.JTextField txtemail; private
javax.swing.JTextArea txtmassage;
// End of variables declaration
}
Create User profile(user_add.java)

Code:

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;

P a g e 241 |
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
public class user_add extends javax.swing.JFrame {

/**
* Creates new form user_add
*/
public user_add() {
initComponents();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
//get current date time with Date()
Date date = new Date();
accountdate.setText(dateFormat.format(date));

Statement st;
Connection cn;
ResultSet rs;
String sql,p;
boolean q;
int addno;

sql = "select id from userinfo order by id desc";


try {
Class.forName("com.mysql.jdbc.Driver");
cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "sandip");
st = cn.createStatement();
rs = st.executeQuery(sql);
if (rs.next()) {
addno = rs.getInt("id");
addno = addno + 1;
} else {
addno = 1;
}
lblacid.setText("" + addno);
} catch (Exception e) {
JOptionPane.showMessageDialog(rootPane, e.getMessage());

P a g e 242 |
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

buttonGroup1 = new javax.swing.ButtonGroup();


jPanel1 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
lblpicture = new javax.swing.JLabel();
txtmobileno = new javax.swing.JTextField();
txtlastname = new javax.swing.JTextField();
txtemailid = new javax.swing.JTextField();
accountdate = new javax.swing.JTextField();
txtpicturename = new javax.swing.JTextField();
txtfirstname = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
txtaddress = new javax.swing.JTextArea();
jLabel13 = new javax.swing.JLabel();
lblacid = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
rmale = new
javax.swing.JRadioButton();
rfemale = new javax.swing.JRadioButton();
txtpassword = new
javax.swing.JPasswordField();
txtconformpassword = new javax.swing.JPasswordField();
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
P a g e 243 |
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setPreferredSize(new java.awt.Dimension(1300, 650));
setResizable(false);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createC
ompoundBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(51, 0, 204),
new java.awt.Color(204, 204, 204)), null), "Fill User Information",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS", 1, 12),
new java.awt.Color(153, 0, 0))); // NOI18N

jLabel2.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel2.setText("First Name :");

jLabel3.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel3.setText("Mobile No :");

jLabel4.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); //


NOI18N jLabel4.setText("Email-id :");

jLabel6.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel6.setText("Password :");

jLabel7.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel7.setText("Conform Password :");

jLabel8.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel8.setText("Last Name :");

jLabel9.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel9.setText("Account Created date :");

jLabel11.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel11.setText("Address :");

lblpicture.setIcon(new javax.swing.ImageIcon(getClass().getResource("/profilepic.png"))); //
NOI18N

txtmobileno.addKeyListener(new java.awt.event.KeyAdapter()
{ public void keyReleased(java.awt.event.KeyEvent evt) {
txtmobilenoKeyReleased(evt);
}
});

P a g e 244 |
txtlastname.addKeyListener(new java.awt.event.KeyAdapter()
{ public void keyReleased(java.awt.event.KeyEvent evt) {
txtlastnameKeyReleased(evt);
}
});

txtemailid.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
txtemailidMouseEntered(evt);
}
});

txtfirstname.setText(" ");
txtfirstname.addKeyListener(new java.awt.event.KeyAdapter()
{ public void keyReleased(java.awt.event.KeyEvent evt) {
txtfirstnameKeyReleased(evt);
}
});

txtaddress.setColumns(20);
txtaddress.setRows(5);
txtaddress.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtaddressKeyReleased(evt);
}
});
jScrollPane1.setViewportView(txtaddress);

jLabel13.setFont(new java.awt.Font("Palatino Linotype", 1, 14)); // NOI18N


jLabel13.setForeground(new java.awt.Color(0, 153, 153));
jLabel13.setText("Account ID :");

lblacid.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N


lblacid.setForeground(new java.awt.Color(0, 0, 102));

jButton3.setText("Brouse");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jLabel5.setFont(new java.awt.Font("Trebuchet MS", 0, 14)); // NOI18N


jLabel5.setText("Gender :");

P a g e 245 |
buttonGroup1.add(rmale);
rmale.setFont(new java.awt.Font("Trebuchet MS", 0, 14)); // NOI18N
rmale.setText("Male");

buttonGroup1.add(rfemale);
rfemale.setFont(new java.awt.Font("Trebuchet MS", 0, 14)); // NOI18N
rfemale.setText("Female");

txtpassword.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseExited(java.awt.event.MouseEvent evt) {
txtpasswordMouseExited(evt);
}
});
txtpassword.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtpasswordActionPerformed(evt);
}
});

txtconformpassword.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
txtconformpasswordMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
txtconformpasswordMouseExited(evt);
}
});
txtconformpassword.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtconformpasswordKeyReleased(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)

P a g e 246 |
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 79,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jLabel3)
.addComponent(jLabel9)
.addComponent(jLabel5))
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment
.TRAILING)
.addComponent(txtmobileno, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtfirstname, javax.swing.GroupLayout.PREFERRED_SIZE,
215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(235, 235, 235)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment
.TRAILING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(accountdate, javax.swing.GroupLayout.PREFERRED_SIZE,
215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel11))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE, 215,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(rmale)
.addGap(91, 91, 91)
.addComponent(rfemale)
.addGap(204, 204, 204))
.addComponent(jLabel4)
.addComponent(jLabel8)))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(109, 109, 109)

P a g e 247 |
.addComponent(lblacid, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.T
RAILING, false)
.addComponent(txtconformpassword,
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtemailid, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
.addComponent(txtlastname, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE))
.addGap(172, 172, 172)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addComponent(lblpicture, javax.swing.GroupLayout.PREFERRED_SIZE, 122,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtpicturename))))
.addGap(47, 47, 47))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG
) .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel13)
.addGap(2, 2, 2))
.addComponent(lblacid, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(25, 25, 25)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel2)
.addComponent(txtfirstname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8)

P a g e 248 |
.addComponent(txtlastname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel3)
.addComponent(txtmobileno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(txtemailid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(37, 37, 37)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtconformpassword, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(34, 34, 34)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jLabel9)
.addComponent(accountdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(48, 48, 48))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(lblpicture, javax.swing.GroupLayout.PREFERRED_SIZE, 153,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtpicturename, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(86, 86, 86)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel5)

P a g e 249 |
.addComponent(rmale)
.addComponent(rfemale))
.addGap(40, 40, 40))
);

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jLabel1.setForeground(new java.awt.Color(156, 0, 0));
jLabel1.setText("Create A User Account");

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jButton1.setText("Cancel");

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jButton2.setText("Submit");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(405, 405, 405)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(67, 67, 67)
.addComponent(jButton2)
.addGap(126, 126, 126))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE,
24, javax.swing.GroupLayout.PREFERRED_SIZE)

P a g e 250 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap(26, Short.MAX_VALUE))
);

setBounds(0, 55, 1275, 538);


}// </editor-fold>

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


Statement st1;
Connection cn1;
boolean q;

String admission, fname, lname, moblieno,email,password,conformpassword,acdate, gender =


"",address,picturename,photo;
int id;
admission = lblacid.getText();
id = Integer.parseInt(admission);

if (rmale.isSelected())
{
gender = rmale.getText();
}
else if (rfemale.isSelected()) {
gender = rfemale.getText();
}

try
{
Class.forName("com.mysql.jdbc.Driver");
cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st1=cn1.createStatement();
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to
Save ?")==JOptionPane.YES_OPTION)
{
String sql = "INSERT INTO userinfo (id,firstname ,
lastname,mobileno ,email,password,repassword,acdate,gender,address,photo) values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

P a g e 251 |
PreparedStatement statement = cn1.prepareStatement(sql);

statement.setInt(1,id );
statement.setString(2,txtfirstname.getText());
statement.setString(3,txtlastname.getText());
statement.setString(4,txtmobileno.getText());
statement.setString(5,txtemailid.getText());
statement.setString(6,txtpassword.getText());
statement.setString(7,txtconformpassword.getText());
statement.setString(8,accountdate.getText());
statement.setString(9,gender);
statement.setString(10,txtaddress.getText());
InputStream inputStream = new FileInputStream(new File(txtpicturename.getText()));
statement.setBlob(11, inputStream);
int row = statement.executeUpdate();
if (row > 0) {

JOptionPane.showMessageDialog(rootPane,"Record is Saved");
}
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}

// TODO add your handling code here:


}

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


JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
File f = chooser.getSelectedFile();
String filename = f.getAbsolutePath();
txtpicturename.setText(filename);
BufferedImage bi;
try
{ //display the image in jlabel
bi=ImageIO.read(f);
lblpicture.setIcon(new ImageIcon(bi));
}

P a g e 252 |
catch(IOException e)
{

}
// TODO add your handling code here:
}

private void txtfirstnameKeyReleased(java.awt.event.KeyEvent evt) {


txtfirstname.setText(txtfirstname.getText().toUpperCase());
// TODO add your handling code here:
}

private void txtmobilenoKeyReleased(java.awt.event.KeyEvent evt) {

// TODO add your handling code here:


}

private void txtlastnameKeyReleased(java.awt.event.KeyEvent evt) {


txtlastname.setText(txtlastname.getText().toUpperCase());
// TODO add your handling code here:
}

private void txtaddressKeyReleased(java.awt.event.KeyEvent evt) {


txtaddress.setText(txtaddress.getText().toUpperCase());

// TODO add your handling code here:


}

private void txtconformpasswordKeyReleased(java.awt.event.KeyEvent evt) {

// TODO add your handling code here:


}

private void txtconformpasswordMouseExited(java.awt.event.MouseEvent evt) {


char[] pass =txtpassword.getPassword();
char[] conpass= txtconformpassword.getPassword();
if (pass.length!= conpass.length) {

JOptionPane.showMessageDialog(rootPane,"Password not matched!");


}

// TODO add your handling code here:


}

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

P a g e 253 |
// TODO add your handling code here:
}

private void txtpasswordMouseExited(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:


}

private void txtconformpasswordMouseEntered(java.awt.event.MouseEvent evt) {


char[] password = txtpassword.getPassword();

if (password.length < 8) {

JOptionPane.showMessageDialog(rootPane,"Password must contain at least 8 characters!");


}
// TODO add your handling code here:
}

private void txtemailidMouseEntered(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:


}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}

P a g e 254 |
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable()
{
public void run() {
new user_add().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField accountdate;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
P a g e 255 |
private javax.swing.JLabel lblacid;
private javax.swing.JLabel lblpicture;
private javax.swing.JRadioButton rfemale;
private javax.swing.JRadioButton rmale;
private javax.swing.JTextArea txtaddress;
private javax.swing.JPasswordField txtconformpassword;
private javax.swing.JTextField txtemailid;
private javax.swing.JTextField txtfirstname;
private javax.swing.JTextField txtlastname;
private javax.swing.JTextField txtmobileno;
private javax.swing.JPasswordField txtpassword;
private javax.swing.JTextField txtpicturename;
// End of variables declaration
}
Modify user (Update_user_profile.java)

Code:

import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

/*

P a g e 256 |
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
public class update_user_profile extends javax.swing.JFrame {

/**
* Creates new form update_student_profile
*/
public update_user_profile() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
txtadmissionno = new
javax.swing.JTextField(); jButton1 = new
javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createE
tchedBorder(new java.awt.Color(204, 204, 204), null), "Update User Profile :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS", 1, 14),
new java.awt.Color(0, 102, 51))); // NOI18N

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel1.setText("Enter User ID :");

jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

P a g e 257 |
jButton1.setText("Search");

P a g e 258 |
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel1)
.addGap(53, 53, 53)
.addComponent(txtadmissionno, javax.swing.GroupLayout.DEFAULT_SIZE, 186,
Short.MAX_VALUE)
.addGap(51, 51, 51)
.addComponent(jButton1)
.addGap(84, 84, 84))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL
ING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(txtadmissionno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addComponent(jLabel1))
.addContainerGap(57, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(48, 48, 48)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(32, Short.MAX_VALUE))
);

P a g e 259 |
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(51, 51, 51)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(113, Short.MAX_VALUE))
);

setBounds(100, 55, 689, 365);


}// </editor-fold>

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


Statement st;
Connection cn;
ResultSet rs;
String admission ,firstname, lastname, mname,password,conpassword,accountdate,gender = "",
contactno, email, address, admissiondate,picturename;
int admissionno,userid;
admission=txtadmissionno.getText();
admissionno=Integer.parseInt(admission);
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from userinfo where id ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{

userid =rs.getInt("id");
firstname=rs.getString("firstname");
lastname=rs.getString("lastname");
contactno=rs.getString("mobileno");
email=rs.getString("email");
password=rs.getString("password");
conpassword=rs.getString("repassword");
accountdate=rs.getString("acdate");
gender=rs.getString("gender");
address=rs.getString("address");
java.sql.Blob blob = rs.getBlob("photo");
user_update myform = new user_update();
myform.lblacid.setText(""+admissionno);

P a g e 260 |
myform.txtfirstname.setText(firstname);
myform.txtlastname.setText(lastname);
myform.txtmobileno.setText(contactno);
myform.txtemailid.setText(email);

if(gender.equals("Male"))
{
myform.rmale.setSelected(true);
}
else
{
myform.rfemale.setSelected(true);
}

myform.txtpassword.setText(password);
myform.txtconformpassword.setText(conpassword);
myform.accountdate.setText(accountdate);
myform.txtaddress.setText(address);

BufferedInputStream is2 = new BufferedInputStream(blob.getBinaryStream());


Image raw = ImageIO.read(is2);
ImageIcon icon = new ImageIcon(raw);
myform.lblpicture.setIcon(icon);

//myform.f1t2.setText(f4t2.getText());
myform.setVisible(true);

// txtroll.setText(""+rollno);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}

// TODO add your handling code here:


}

/**
* @param args the command line arguments
*/

P a g e 261 |
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable()
{
public void run() {
new update_user_profile().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtadmissionno;
P a g e 262 |
// End of variables declaration
}
Update User Account(user_update.java)

Code:
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*

P a g e 263 |
* @author sand
*/
public class user_update extends javax.swing.JFrame {

/**
* Creates new form user_add
*/
String filename ="";
public user_update() {
initComponents();

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

buttonGroup1 = new javax.swing.ButtonGroup();


jPanel1 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
lblpicture = new javax.swing.JLabel();
txtmobileno = new javax.swing.JTextField();
txtlastname = new javax.swing.JTextField();
txtemailid = new javax.swing.JTextField();
accountdate = new javax.swing.JTextField();
txtpicname = new javax.swing.JTextField();
txtfirstname = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
txtaddress = new javax.swing.JTextArea();
jLabel13 = new javax.swing.JLabel();
lblacid = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();

P a g e 264 |
jLabel5 = new javax.swing.JLabel();
rmale = new
javax.swing.JRadioButton();
rfemale = new javax.swing.JRadioButton();
txtpassword = new
javax.swing.JPasswordField();
txtconformpassword = new javax.swing.JPasswordField();
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createC
ompoundBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(51, 0, 204),
new java.awt.Color(204, 204, 204)), null), "Update User Information :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS", 1, 12),
new java.awt.Color(153, 0, 0))); // NOI18N

jLabel2.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel2.setText("First Name :");

jLabel3.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel3.setText("Mobile No :");

jLabel4.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); //


NOI18N jLabel4.setText("Email-id :");

jLabel6.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel6.setText("Password :");

jLabel7.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel7.setText("Conform Password :");

jLabel8.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel8.setText("Last Name :");

jLabel9.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel9.setText("Account Created date :");

jLabel11.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N


jLabel11.setText("Address :");

P a g e 265 |
lblpicture.setIcon(new javax.swing.ImageIcon(getClass().getResource("/profilepic.png"))); //
NOI18N

txtmobileno.addKeyListener(new java.awt.event.KeyAdapter()
{ public void keyReleased(java.awt.event.KeyEvent evt) {
txtmobilenoKeyReleased(evt);
}
});

txtlastname.addKeyListener(new java.awt.event.KeyAdapter()
{ public void keyReleased(java.awt.event.KeyEvent evt) {
txtlastnameKeyReleased(evt);
}
});

txtemailid.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
txtemailidMouseEntered(evt);
}
});

txtfirstname.setText(" ");
txtfirstname.addKeyListener(new java.awt.event.KeyAdapter()
{ public void keyReleased(java.awt.event.KeyEvent evt) {
txtfirstnameKeyReleased(evt);
}
});

txtaddress.setColumns(20);
txtaddress.setRows(5);
txtaddress.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtaddressKeyReleased(evt);
}
});
jScrollPane1.setViewportView(txtaddress);

jLabel13.setFont(new java.awt.Font("Palatino Linotype", 1, 14)); // NOI18N


jLabel13.setForeground(new java.awt.Color(0, 153, 153));
jLabel13.setText("Account ID :");

lblacid.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N


lblacid.setForeground(new java.awt.Color(0, 0, 102));

jButton3.setText("Brouse");

P a g e 266 |
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jLabel5.setFont(new java.awt.Font("Trebuchet MS", 0, 14)); // NOI18N


jLabel5.setText("Gender :");

buttonGroup1.add(rmale);
rmale.setFont(new java.awt.Font("Trebuchet MS", 0, 14)); // NOI18N
rmale.setText("Male");

buttonGroup1.add(rfemale);
rfemale.setFont(new java.awt.Font("Trebuchet MS", 0, 14)); // NOI18N
rfemale.setText("Female");

txtpassword.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseExited(java.awt.event.MouseEvent evt) {
txtpasswordMouseExited(evt);
}
});
txtpassword.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtpasswordActionPerformed(evt);
}
});

txtconformpassword.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
txtconformpasswordMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
txtconformpasswordMouseExited(evt);
}
});
txtconformpassword.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtconformpasswordKeyReleased(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

P a g e 267 |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 79,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jLabel3)
.addComponent(jLabel9)
.addComponent(jLabel5))
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment
.TRAILING)
.addComponent(txtmobileno, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtfirstname, javax.swing.GroupLayout.PREFERRED_SIZE,
215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(235, 235, 235)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment
.TRAILING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(accountdate, javax.swing.GroupLayout.PREFERRED_SIZE,
215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel11))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE, 215,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(rmale)
.addGap(91, 91, 91)

P a g e 268 |
.addComponent(rfemale)
.addGap(204, 204, 204))
.addComponent(jLabel4)
.addComponent(jLabel8)))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(109, 109, 109)
.addComponent(lblacid, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.T
RAILING, false)
.addComponent(txtconformpassword,
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtemailid, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
.addComponent(txtlastname, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE))
.addGap(172, 172, 172)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addComponent(lblpicture, javax.swing.GroupLayout.PREFERRED_SIZE, 122,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtpicname))))
.addGap(47, 47, 47))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG
) .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel13)
.addGap(2, 2, 2))

P a g e 269 |
.addComponent(lblacid, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(25, 25, 25)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel2)
.addComponent(txtfirstname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8)
.addComponent(txtlastname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel3)
.addComponent(txtmobileno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(txtemailid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(37, 37, 37)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtconformpassword, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(34, 34, 34)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jLabel9)
.addComponent(accountdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(48, 48, 48))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(lblpicture, javax.swing.GroupLayout.PREFERRED_SIZE, 153,
javax.swing.GroupLayout.PREFERRED_SIZE)

P a g e 270 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtpicname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(86, 86, 86)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel5)
.addComponent(rmale)
.addComponent(rfemale))
.addGap(40, 40, 40))
);

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jLabel1.setForeground(new java.awt.Color(156, 0, 0));
jLabel1.setText("Update User Account :-");

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jButton1.setText("Delete");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jButton2.setText("Update");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(405, 405, 405)

P a g e 271 |
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(71, 71, 71)
.addComponent(jButton2)
.addGap(134, 134, 134))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE,
24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton2)
.addComponent(jButton1))
.addGap(80, 80, 80))
);

setBounds(0, 55, 1275, 660);


}// </editor-fold>

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

Statement st1;
Connection cn1;
boolean q;

String firstname,lastname, mobileno,teachername,password,conpass, acdate,address, gender =


"", email;
int id,rollno;
String picturename ="";

id = Integer.parseInt(lblacid.getText());
firstname= txtfirstname.getText();
lastname=txtlastname.getText();
mobileno= txtmobileno.getText();

P a g e 272 |
email= txtemailid.getText();
password= txtpassword.getText();
conpass=txtconformpassword.getText();
acdate=accountdate.getText();

if (rmale.isSelected())
{
gender = rmale.getText();
}
else if (rfemale.isSelected()) {
gender = rfemale.getText();
}
address= txtaddress.getText();
picturename =txtpicname.getText();

try
{
Class.forName("com.mysql.jdbc.Driver");
cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
// st1=cn1.createStatement();
if(filename.equals(""))
{

if(JOptionPane.showConfirmDialog(rootPane, "Do you want to


Save ?")==JOptionPane.YES_OPTION)
{
PreparedStatement statement = cn1.prepareStatement("UPDATE userinfo SET firstname
= ?,lastname = ?,mobileno = ?,email = ? ,password = ? ,repassword = ?,acdate= ?,gender = ?,address
= ? WHERE id = "+id+""); //ps.setString(1, (String) jTable1. getValueAt(x, 0));

statement.setString(1,firstname);
statement.setString(2,lastname);
statement.setString(3,mobileno);
statement.setString(4,email);
statement.setString(5,password);
statement.setString(6,conpass);
statement.setString(7,acdate);
statement.setString(8,gender);
statement.setString(9,address);
int row = statement.executeUpdate();

P a g e 273 |
if (row > 0)
{

JOptionPane.showMessageDialog(rootPane,"Record is Succesfully updated without photo");


}
}
}
else
{
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to
Save ?")==JOptionPane.YES_OPTION)
{
PreparedStatement statement = cn1.prepareStatement("UPDATE userinfo SET firstname
= ?,lastname = ?,mobileno = ?,email = ? ,password = ? ,repassword = ?,acdate= ?,gender = ?,address
= ?,photo = ? WHERE id = "+id+""); //ps.setString(1, (String) jTable1. getValueAt(x, 0));
statement.setString(1,firstname);
statement.setString(2,lastname);
statement.setString(3,mobileno);
statement.setString(4,email);
statement.setString(5,password);
statement.setString(6,conpass);
statement.setString(7,acdate);
statement.setString(8,gender);
statement.setString(9,address);
InputStream inputStream = new FileInputStream(new File(txtpicname.getText()));
statement.setBlob(10, inputStream);
int row = statement.executeUpdate();
if (row > 0)
{

JOptionPane.showMessageDialog(rootPane,"Record is Succesfully updated with photo");


}
}
}
}

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

// TODO add your handling code here:


}

P a g e 274 |
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
File f = chooser.getSelectedFile();
filename = f.getAbsolutePath();
txtpicname.setText(filename);
BufferedImage bi;
try
{ //display the image in jlabel
bi=ImageIO.read(f);
lblpicture.setIcon(new ImageIcon(bi));
}
catch(IOException e)
{

}
// TODO add your handling code here:
}

private void txtfirstnameKeyReleased(java.awt.event.KeyEvent evt) {


txtfirstname.setText(txtfirstname.getText().toUpperCase());
// TODO add your handling code here:
}

private void txtmobilenoKeyReleased(java.awt.event.KeyEvent evt) {

// TODO add your handling code here:


}

private void txtlastnameKeyReleased(java.awt.event.KeyEvent evt) {


txtlastname.setText(txtlastname.getText().toUpperCase());
// TODO add your handling code here:
}

private void txtaddressKeyReleased(java.awt.event.KeyEvent evt) {


txtaddress.setText(txtaddress.getText().toUpperCase());

// TODO add your handling code here:


}

private void txtconformpasswordKeyReleased(java.awt.event.KeyEvent evt) {

// TODO add your handling code here:


}

P a g e 275 |
private void txtconformpasswordMouseExited(java.awt.event.MouseEvent evt) {
char[] pass =txtpassword.getPassword();
char[] conpass= txtconformpassword.getPassword();
if (pass.length!= conpass.length) {

JOptionPane.showMessageDialog(rootPane,"Password not matched!");


}

// TODO add your handling code here:


}

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

// TODO add your handling code here:


}

private void txtpasswordMouseExited(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:


}

private void txtconformpasswordMouseEntered(java.awt.event.MouseEvent evt) {


char[] password = txtpassword.getPassword();

if (password.length < 8) {

JOptionPane.showMessageDialog(rootPane,"Password must contain at least 8 characters!");


}
// TODO add your handling code here:
}

private void txtemailidMouseEntered(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:


}

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


Statement st;
Connection cn;
ResultSet rs;
String admission, uname;

P a g e 276 |
int id;
admission = lblacid.getText();
id=Integer.parseInt(admission);
uname =txtfirstname.getText();
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

st=cn.createStatement();

//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to Delete name =
"+uname)==JOptionPane.YES_OPTION)

{
String p1="delete from userinfo where id='"+id+"'";

st.execute(p1);

//st1.execute(p1);

}
st.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {

P a g e 277 |
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable()
{
public void run() {
new user_update().setVisible(true);
}
});
}
// Variables declaration - do not modify
public javax.swing.JTextField accountdate;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
P a g e 278 |
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
public javax.swing.JLabel lblacid;
public javax.swing.JLabel lblpicture;
public javax.swing.JRadioButton rfemale;
public javax.swing.JRadioButton rmale;
public javax.swing.JTextArea txtaddress;
public javax.swing.JPasswordField txtconformpassword;
public javax.swing.JTextField txtemailid;
public javax.swing.JTextField txtfirstname;
public javax.swing.JTextField txtlastname;
public javax.swing.JTextField txtmobileno;
public javax.swing.JPasswordField txtpassword;
private javax.swing.JTextField txtpicname;
// End of variables declaration
}
Delete User Account(delete_user_profile.java)

Code:

import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;

P a g e 279 |
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
public class delate_user_profile extends javax.swing.JFrame {

/**
* Creates new form update_student_profile
*/
public delate_user_profile() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
txtadmissionsearch = new
javax.swing.JTextField(); jButton1 = new
javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createE
tchedBorder(new java.awt.Color(204, 204, 204), null), "Delate User Profile :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS", 1, 14),
new java.awt.Color(102, 0, 102))); // NOI18N

P a g e 280 |
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

P a g e 281 |
jLabel1.setText("Enter User ID :");

txtadmissionsearch.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseMoved(java.awt.event.MouseEvent evt) {
txtadmissionsearchMouseMoved(evt);
}
});
txtadmissionsearch.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtadmissionsearchKeyReleased(evt);
}
});

jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jButton1.setText("Delete");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jButton1KeyPressed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel1)
.addGap(53, 53, 53)
.addComponent(txtadmissionsearch, javax.swing.GroupLayout.DEFAULT_SIZE,
151, Short.MAX_VALUE)
.addGap(51, 51, 51)
.addComponent(jButton1)
.addGap(84, 84, 84))
);

P a g e 282 |
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL
ING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(txtadmissionsearch, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addComponent(jLabel1))
.addContainerGap(57, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(43, 43, 43)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(50, Short.MAX_VALUE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(57, Short.MAX_VALUE))
);

setBounds(100, 55, 667, 286);


}// </editor-fold>

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


Statement st;
Connection cn;
ResultSet rs;
String admission, sname;
int admissionno;
admission =
txtadmissionsearch.getText();

P a g e 283 |
admissionno=Integer.parseInt(admission);

P a g e 284 |
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

st=cn.createStatement();

//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Are u Sure Delete This
Profile?")==JOptionPane.YES_OPTION)

{
String p1="delete from userinfo where id='"+admissionno+"'";

st.execute(p1);

//st1.execute(p1);

}
st.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
// TODO add your handling code here:
}

private void jButton1KeyPressed(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
}

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {


// TODO add your handling code here:
}

private void txtadmissionsearchKeyReleased(java.awt.event.KeyEvent evt) {


Statement st;
Connection cn;
ResultSet rs;
String admission,studentname;
int admissionno,date ,year;

P a g e 285 |
admission=txtadmissionsearch.getText();
admissionno=Integer.parseInt(admission);
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from userinfo where id ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{
studentname=rs.getString("firstname");

JOptionPane.showMessageDialog(null, "Do You want to Delete ,"+ studentname + "


Profile Click Delete Button");

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

// TODO add your handling code here:


}

private void txtadmissionsearchMouseMoved(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:


}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {

P a g e 286 |
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable()
{
public void run() {
new delate_user_profile().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtadmissionsearch;
// End of variables declaration
}

P a g e 287 |
Search User information(user_information.java)

Code:
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.table.DefaultTableModel;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
import java.sql.*;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

P a g e 288 |
import javax.swing.table.DefaultTableModel;
public class user_information extends javax.swing.JFrame {

/**
* Creates new form studentdetails
*/
public user_information() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel3 = new javax.swing.JPanel();


jPanel2 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jLabel1 = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton7 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "All Records of Users :",


javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new
java.awt.Color(0, 153, 153))); // NOI18N

P a g e 289 |
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {

},
new String [] {
"User Id.", "First Name.", "Last Name.", "Contact No.", "Email", "Address.", "gender"
}
));
jScrollPane1.setViewportView(jTable1);

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);


jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 702,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(28, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 215,
Short.MAX_VALUE)
.addContainerGap())
);

jScrollPane2.setViewportView(jTextPane1);

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


jLabel1.setText("User Report Preview :");

jButton3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton3.setText("Update");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton2.setText("Register");
jButton2.addActionListener(new java.awt.event.ActionListener() {

P a g e 290 |
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jButton6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton6.setText("Print");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});

jButton8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton8.setText("Preview");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});

jButton4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton4.setText("DELETE");
jButton4.addActionListener(new java.awt.event.ActionListener()
{ public void actionPerformed(java.awt.event.ActionEvent evt)
{
jButton4ActionPerformed(evt);
}
});

jButton5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton5.setText("Exit");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});

jButton1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton1.setText("Show-details ");
jButton1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
P a g e 291 |
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inbo.png"))); // NOI18N
jLabel3.setText(" ");

jButton7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jButton7.setText("Search");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);


jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAI
LING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(451, 451, 451)
.addComponent(jButton1))
.addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TR
AILING, false)
.addComponent(jScrollPane2)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD
ING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(18, 72, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE,
109, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)

P a g e 292 |
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(45, 45, 45))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 196,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addContainerGap(20, Short.MAX_VALUE))))
);
jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD
ING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel3Layout.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(jButton3)
.addGap(27, 27, 27)
.addComponent(jButton4)
.addGap(18, 18, 18)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton7)
.addGap(13, 13, 13)
.addComponent(jButton6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton5)
.addGap(25, 25, 25)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 261,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE,
0, Short.MAX_VALUE))))
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

P a g e 293 |
.addGap(2, 2, 2)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jLabel1)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 219,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addComponent(jButton8)
.addContainerGap(30, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

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


DefaultTableModel model = ( DefaultTableModel)jTable1.getModel();
Statement st1;
boolean q;
Connection cn;
ResultSet rs;
String firstname,lastname,mobileno,email,password,address;
int id=0;

try
{

P a g e 294 |
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

st1=cn.createStatement();
String p="select id,firstname,lastname,mobileno,email,address,password from userinfo";
rs=st1.executeQuery(p);
while (rs.next())
{
id = rs.getInt("id");
firstname= rs.getString("firstname");
lastname= rs.getString("lastname");
mobileno= rs.getString("mobileno");
email= rs.getString("email");
address= rs.getString("address");
password = rs.getString("password");
model.addRow(new
Object[]{id,firstname,lastname,mobileno,email,address,password});
}
//DefaultTableModel model = (DefaultTableModel) table.getModel();
st1.close();

cn.close();

}
catch(Exception e)
{
System.out.println(e.getMessage());
}

// TODO add your handling code here:


}

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


user_add myform = new user_add();
myform.setVisible(true);
// TODO add your handling code here:
}

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


if(JOptionPane.showConfirmDialog(rootPane, "Do you Want to
Exit ?")==JOptionPane.YES_OPTION)
this.dispose();
// TODO add your handling code here:
}

P a g e 295 |
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
try {
if (! jTable1.print()) {
System.err.println("User cancelled printing");
}
} catch (java.awt.print.PrinterException e) {
System.err.format("Cannot print %s%n", e.getMessage());
}

// TODO add your handling code here:


}

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


{ int x=jTable1.getSelectedRow();
String d=jTable1.getValueAt(x,
0).toString(); String
n=jTable1.getValueAt(x, 1).toString();
Statement st1;
boolean q;
Connection cn;
ResultSet rs;
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");

st1=cn.createStatement();

//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to Delete name =
"+n)==JOptionPane.YES_OPTION)

{
String p1="delete from userinfo where id='"+d+"'";

st1.execute(p1);

//st1.execute(p1);

DefaultTableModel model = ( DefaultTableModel)jTable1.getModel();


model.removeRow(x);
}
st1.close();
cn.close();
}

P a g e 296 |
catch(Exception e)

P a g e 297 |
{
System.out.println(e.getMessage());
}

// TODO add your handling code here:


}

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


int x=jTable1.getSelectedRow();

String d=jTable1.getValueAt(x,0).toString();
int id=Integer.parseInt(d);

//do the update query on this row

try {
Class.forName("com.mysql.jdbc.Driver");
if(JOptionPane.showConfirmDialog(rootPane, "Want to UPDATE id =
"+d)==JOptionPane.YES_OPTION)
{
Connection cn=
DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
PreparedStatement ps = cn.prepareStatement("UPDATE userinfo SET firstname
= ? ,lastname = ?,mobileno = ?,email = ?,address = ?,gender= ? WHERE id = "+id+"");
//ps.setString(1, (String) jTable1. getValueAt(x, 0));

ps.setString(1, (String) jTable1.getValueAt(x, 1));


ps.setString(2, (String) jTable1.getValueAt(x, 2));
ps.setString(3, (String) jTable1.getValueAt(x, 3));
ps.setString(4, (String) jTable1.getValueAt(x, 4));
ps.setString(5, (String) jTable1.getValueAt(x, 5));
ps.setString(6, (String) jTable1.getValueAt(x, 6));

ps.executeUpdate();
ps.close();
cn.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
// TODO add your handling code here:
}

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

P a g e 298 |
// TODO add your handling code here:
}

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


update_user_profile myform = new update_user_profile();
myform.setVisible(true);
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logging.Level
.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logging.Level
.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logging.Level
.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logging.Level
.SEVERE, null, ex);
}
//</editor-fold>

P a g e 299 |
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new user_information().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane
jScrollPane2; private javax.swing.JTable
jTable1;
private javax.swing.JTextPane jTextPane1;
// End of variables declaration

Help Form(Help.java)

P a g e 300 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
public class help extends javax.swing.JFrame {

/**
* Creates new form help
*/
public help() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always

P a g e 301 |
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new
javax.swing.JLabel(); jLabel7 = new
javax.swing.JLabel(); jLabel8 =
new javax.swing.JLabel(); jLabel4
= new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setAlwaysOnTop(true);

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N


jLabel1.setText("Some following steps :");

jLabel2.setText("1. First of all create database in which u want to import database in my sql. ");

jLabel3.setText("2. Use this database.");

jLabel5.setText("3. Path ->sql file name.");

jLabel6.setText("4. Example:- \\. E:\\career.sql ");

jLabel7.setText(" -> here e: is a drive name nd career.sql is database who is already u have.");

jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/restorepic.png"))); //
NOI18N

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG
) .addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()

P a g e 302 |
.a
d
d
C
o
m
p
o
ne
nt
(j
La
be
l1)
)

P a g e 303 |
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel7)))
.addComponent(jLabel8))
.addContainerGap(47, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 304,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

jLabel4.setFont(new java.awt.Font("Trebuchet MS", 1, 14)); // NOI18N


jLabel4.setText("How to Import/ Restore Database in My SQL 5.5 Command Line:-");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()

P a g e 304 |
.addGap(123, 123, 123)
.addComponent(jLabel4)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(25, 25, 25)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width-
724)/2, (screenSize.height-546)/2, 724, 546);
}// </editor-fold>

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(help.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(help.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(help.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

P a g e 305 |
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

P a g e 306 |
java.util.logging.Logger.getLogger(help.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable()
{
public void run() {
new help().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}
Change user password(Change _user_ password.java)

Code :
import java.io.File;
P a g e 307 |
import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author sand
*/
public class change_user_password_form extends javax.swing.JFrame {

/**
* Creates new form change_user_password_form
*/
public change_user_password_form()
{ initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtpass = new javax.swing.JTextField();
txtconpass = new javax.swing.JTextField();
txtoldpass = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();

P a g e 308 |
jLabel5 = new javax.swing.JLabel();
userid = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
lblname = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder(new
java.awt.Color(204, 204, 204), new java.awt.Color(204, 204, 204)));

jLabel1.setText("Password :");

jLabel2.setText("Conform password :");

jLabel3.setText("Old Password :");

jButton1.setText("CHANGE");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(67, 67, 67)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addComponent(jLabel3)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(59, 59, 59)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addComponent(txtpass)
.addComponent(txtoldpass, javax.swing.GroupLayout.DEFAULT_SIZE, 166,
Short.MAX_VALUE)
.addComponent(txtconpass, javax.swing.GroupLayout.Alignment.LEADING))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

P a g e 309 |
.addComponent(jButton1)
.addGap(155, 155, 155))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel1)
.addComponent(txtpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel2)
.addComponent(txtconpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel3)
.addComponent(txtoldpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35,
Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(20, 20, 20))
);

jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N


jLabel4.setText("CHANGE USER PASSWORD :");

jLabel5.setText("Enter User Id :");

userid.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
useridKeyReleased(evt);
}
});

jLabel6.setText("Name :");

lblname.setText(" ");

P a g e 310 |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL
ING
) .addGroup(layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED

) .addComponent(userid, javax.swing.GroupLayout.PREFERRED_SIZE, 72,


javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel6)
.addGap(18, 18, 18)
.addComponent(lblname, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(0, 56, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.T
RAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(86, 86, 86))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(55, 55, 55))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel4)
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASEL
INE)
.addComponent(jLabel5)
.addComponent(userid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(lblname))

P a g e 311 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(45, Short.MAX_VALUE))
);

setBounds(300, 110, 540, 334);


}// </editor-fold>

private void useridKeyReleased(java.awt.event.KeyEvent evt) {


Statement st;
Connection cn;
ResultSet rs;
String admission,username;
int admissionno,date ,year;
admission=userid.getText();
admissionno=Integer.parseInt(admission);
try
{
Class.forName("com.mysql.jdbc.Driver");

cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from userinfo where id ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{
username=rs.getString("firstname");
lblname.setText(username);

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

// TODO add your handling code here:


}

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

Statement st1;

P a g e 312 |
Connection cn1;
boolean q;

String pass,conpass,oldpass;
int admissionno,id;

id =

Integer.parseInt(userid.getText());

pass= txtpass.getText();
conpass= txtconpass.getText();
oldpass= txtoldpass.getText();

try
{
Class.forName("com.mysql.jdbc.Driver");

cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to change your
password?")==JOptionPane.YES_OPTION)
{
PreparedStatement statement = cn1.prepareStatement("UPDATE userinfo SET
password= ?,repassword = ? WHERE id = "+id+""); //ps.setString(1, (String) jTable1.
getValueAt(x, 0));
statement.setString(1,pass);
statement.setString(2,conpass);
int row =
statement.executeUpdate(); if (row >
0)
{
JOptionPane.showMessageDialog(rootPane,"Passwword is Succesfully Changed ");
}
}

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

// TODO add your handling code here:


}

P a g e 313 |
/**
* @param args the command line arguments

P a g e 314 |
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new change_user_password_form().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;

P a g e 315 |
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel
lblname;
private javax.swing.JTextField txtconpass;
private javax.swing.JTextField txtoldpass;
private javax.swing.JTextField txtpass;
private javax.swing.JTextField userid;
// End of variables declaration
}
Change admin password(Change_admin_password.java)

Code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**

P a g e 316 |
*
* @author sand
*/
public class change_admin_password_form extends javax.swing.JFrame {

/**
* Creates new form change_user_password_form
*/
public change_admin_password_form() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtpass = new javax.swing.JTextField();
txtconpass = new javax.swing.JTextField();
txtoldpass = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

jLabel1.setText("Password :");

jLabel2.setText("Conform password :");

jLabel3.setText("Old Password :");

jButton1.setText("CHANGE");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

P a g e 317 |
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(67, 67, 67)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel3)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(59, 59, 59)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(txtpass)
.addComponent(txtoldpass, javax.swing.GroupLayout.DEFAULT_SIZE, 166,
Short.MAX_VALUE)
.addComponent(txtconpass,
javax.swing.GroupLayout.Alignment.LEADING)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(159, 159, 159)
.addComponent(jButton1)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel1)
.addComponent(txtpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel2)
.addComponent(txtconpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)

P a g e 318 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel3)
.addComponent(txtoldpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36,
Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(19, 19, 19))
);

jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N


jLabel4.setForeground(new java.awt.Color(51, 0, 0));
jLabel4.setText("CHANGE ADMIN PASSWORD :");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(29, 29, 29))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(126, 126, 126))))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel4)
.addGap(20, 20, 20)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

pack();

P a g e 319 |
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
java.awt.Dimension dialogSize = getSize();
setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-
dialogSize.height)/2);
}// </editor-fold>

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

Statement st1;
Connection cn1;
boolean q;

String pass,conpass,oldpass;
int admissionno,id;

id=2;
pass= txtpass.getText();
conpass= txtconpass.getText();
oldpass= txtoldpass.getText();

try
{
Class.forName("com.mysql.jdbc.Driver");

cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to change your
password?")==JOptionPane.YES_OPTION)
{
PreparedStatement statement = cn1.prepareStatement("UPDATE login SET
password= ? WHERE id = "+id+""); //ps.setString(1, (String) jTable1. getValueAt(x, 0));
statement.setString(1,pass);

int row = statement.executeUpdate();


if (row > 0)
{
JOptionPane.showMessageDialog(rootPane,"Passwword is Succesfully Changed ");
}
}

catch(Exception e)

P a g e 320 |
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}

// TODO add your handling code here:


}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

P a g e 321 |
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new change_admin_password_form().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtconpass;
private javax.swing.JTextField txtoldpass;
private javax.swing.JTextField txtpass;
// End of variables declaration
}

BIBLIOGRAPHY

 Software Engineering, by Roger S. Pressman.


 MYsql: The Complete Reference
CONCURRENT PROGRAMMING IN JAVA by Doug Lea
 Black Book by Steven Holzner et al.

P a g e 322 |

You might also like