School System File
School System File
A PROJECT ON
“SCHOOLMANAGEMENT SYSTEM”
Submitted By : Submitted To :
0
CERTIFICATE .
Date : Date :
ID – SHEET
Roll No : ………………………….
Address : ………………………….
………………………….
Phone No : ………………………….
Supervisor : ………………………….
Student Name
TABLE OF CONTENTS
Introduction
Java Details
Priliminary Design
Form Layouts
Database Design
Implementation
Bibliography
Teacher Remarks
INTRODUCTION
project.
What is java?
Java is a general purpose object oriented programming language . It is the first programming
language that is not tied to any particular hardware or operating system .The language is
based on the concept of an object. Java is highly derived from C++ . Most striking feature of
the language is that it is platform neutral language.
There were five primary goals in the creation of the Java language:
Java tools
In order to write java application or applets ,one need more than a language . The tools that
lets one to write , test , debug programs.
Java features
● Compiler and Interpreted
● Platform independent
● Simple
● Secure
● Familiar
● Portable
● Object-Oriented
● Robust
● Multithreaded
● High performance
● Distributed
● Dynamic
Compiler and Interpreted -There is a java compiler , named javac . The java compiler
takes input source code files (these files typically have the ext.java) and converts them into
compiled bytecode files.The java Interpreter known as javac can be used to execute java
application .The interpreter translates bytecode directly into program actions.
Platform independent- Java programs can be easily moved from one computer to
another, anywhere and anytime.Changes and upgradesmade in operatingsystems,
processors and system resources will not force any changes in java programs.
Simple - Java is designed to be easy for programmer to learn and use efficiently.
Secure- When we use a java compatible web browser, we can safely download java applets
without fear of virus infection. Java achieves this protection by confining a java program to
java execution environment and not allowing it access to other parts of the computer.
Portable- Java compiler generates bytecode instructions that can be implemented on any
machine and also the size of the primitive data types are machine independent.
Object-Oriented - Java is a true object-oriented language. All program code and data
reside within objects and classes.
Robust -It provides many safeguards to ensure reliable code. It has strict compile time and
run time checking for data types. Designed as a garbage-collected language relieving the
programmers and also incorpates the concept of exception handling which captures series
errors.
Distributed- It has ability to share both data and programs. Java applications can open and
access remote objects on internet which enables multiple programmers at multiple remote
locations to collaborate and work together on single project.
Dynamic - Java is capable of dynamically in new class libraries , methods and objects .It
supports functions written in other languages like C,C++ called as native methods.
Automatic garbage collection -One idea behind Java's automatic memory management
model is that programmers should be spared the burden of having to perform manual
memory management. In some languages the programmer allocates memory to create any
object stored on the heap and is responsible for later manually deallocating that memory to
delete any such objects. If a programmer forgets to de-allocate memory or writes code that
fails to do so in a timely fashion, a memory leak can occur: the program will consume a
potentially arbitrarily large amount of memory. In addition, if a region of memory is de-
allocated twice, the program can become unstable and may crash.
In Java, this potential problem is avoided by automatic garbage collection. The programmer
determines when objects are created and the Java runtime is responsible for managing the
objects' lifecycle. The program or other objects can reference an object by holding a
reference to it (which, from a low-level point of view, is its address on the heap). When no
references to an object remain, the Java garbage collector automatically deletes the
unreachable object, freeing memory and preventing a memory leak. Memory leaks may still
occur if a programmer's code holds a reference to an object that is no longer needed—in
other words, they can still occur but at higher conceptual levels.
Comparing Java and C++, it is possible in C++ to implement similar functionality (for
example, a memory management model for specific classes can be designed in C++ to
improve speed and lower memory fragmentation considerably), with the possibly cost of
extra development time and some application complexity. In Java, garbage collection is built
in and virtually invisible to the developer. That is, developers may have no notion of when
garbage collection will take place as it may not necessarily correlate with any actions being
explicitly performed by the code they write. Depending on intended application, this can be
beneficial or disadvantageous: the programmer is freed from performing low-level tasks but
at the same time lose the option of writing lower level code.
Objects and Classes -An object is a software bundle of variables and related methods.
Objects are key to understanding object-oriented technology. Real-world objects share two
characteristics: They all have state and behavior.
Software objects are modeled after real-world objects in that they too have state and
behaviorClasses can also define class variables. A class variable contains information that is
shared by all instances of the class .A class can also declare class methods. You can invoke a
class method directly from the class, whereas you must invoke instance methods on a
particular instance.
Encapsulation - Wrapping of data and methods into a single unit is known as
encapsulation. It is the most striking feature of class. The data is not accessible to outside
world and only those methods which are wrapped in the class can access it. The insulation
of the data from direct access by the program is called data hiding.
Inheritance - Inheritance is the process by which objects of one class acquire the property
of objects of another class. Each subclass inherits state .However, subclasses are not limited
to the states and behaviors provided to them by their superclass. Subclasses can add
variables and methods to the ones they inherit from the superclass. It supports the concept
of hierarchical classification it also provides the use of reusability. .
Polymorphism - This means the ability to take more than one form. An operation may
exhibit different behaviour in different instances. The behaviour depends upon the types of
data used in the operation. It plays an important role in allowing objects having different
internal structures to share external interface.
The Java Database Connectivity (JDBC) API is the industry standard for database-
independent connectivity between the Java programming language and a wide range of
databases – SQL databases and other tabular data sources, such as spreadsheets or flat files.
The JDBC API provides a call-level API for SQL-based database access.
JDBC technology allows you to use the Java programming language to exploit "Write Once,
Run Anywhere" capabilities for applications that require access to enterprise data. With a
JDBC technology-enabled driver, you can connect all corporate data even in a
heterogeneous environment.
Advantages of JDBC Technology :
Driver
Database
Database
The JDBC architecture is based on a collection of java interfaces and classes that together enable you
to connect to data sources , to create and execute SQL statements and to retrieve and modify data in
a database.
The JDBC-ODBC Bridge –“sun.jdbc.odbc.jdbcodbcDriver”-is included with JDK and it enables Java
applications to access data through drivers written to the ODBC standard. The driver bridge is useful
for accessing data in data sources for which no pure JDBC drivers exist. The bridge works by
translating the JDBC methods into ODBC function calls.
● Data Defination Language (DDL) – DDL statements are used to describe the tables
and the data they contain. The subset of SQL statements used for modeling the structure
(rather than the contents) of a database or cube. The DDL gives you the ability to create,
modify, and remove databases and database objects.
● Data Manipulation Language (DML) – DML statements that are used to operate on
data in the database. These are statements that allow you to create or alter objects (such as
tables, indexes, views, and so on) in the database. The subset of SQL statements used to
retrieve and manipulate data. DML can be further divided into 2 groups:-
SELECT - SQL statement used to request a selection, projection, join, query, and so on,
from a SQL Server database.
Primary key – Primary key constraints identify the column or set of columns whose values
uniquely identify a row in a table. No two rows in a table can have the same primary key
value. You cannot enter a NULL value for any column in a primary key.
Insert- The Insert logical operator inserts each row from its input into the object specified
in the Argument column. To insert the data into a relation we either specify a tuple to be
inserted or write a query.
Delete- The Delete logical operator deletes from an object rows that satisfy the optional
predicate in the Argument column. We can delete only whole tuples; we cannot delete
values on only particular attributes.
Update- The Update logical operator updates each row from its input in the object
specified in the Argument column. It provides a way of modifying existing data in a table.
SWING
SWING is a set of classes that provides powerful and flexible functionality. In addition with
several components provided by AWT, swing supplies several exciting additions, including
tabbed panes, scroll panes, trees and tables. It also changes the images as the state of any
component changes. Swing is built upon the foundation of the AWT. Swing components are
written entirely in Java and therefore are Platform-independent .Swing is also termed also
light-weight and provide pluggable look and feel.
There are 2 Swing classes that are quite important:
Jframe and Component – Jframe extends the AWT class Frame. It contains additional
features that enable it to support Swing components. JComponent extends the AWT
component and Container classes. It is the top level class for all Swing components and
provides Swing pluggable look and feel.
Here are some of the Swing component classes:
CLASS DESCRIPTION
Abstract Button Abstract super class for Swing buttons.
Button Group Encapsulates a mutually exclusive set of
buttons.
Image Icon Encapsulates an icon.
JApplet The SWING version of APPLET.
JButton The SWING push button class.
JCheckBox The SWING check box class.
JComboBox Encapsulates a combo box .
JLabels The SWING version of a label.
JRadioButton The SWING version of a radio button.
JScrollPane Encapsulates a scrollable window.
JTabbedPane Encapsulates a tabbed window.
JTextField The SWING version of Text field.
JTree Encapsulates a tree based-control.
● Icons – Icons are encapsulated by the Image Icon class, which paints an icon from an
image.
● JLabel – Labels are the instances of the JLabel class which extends JComponent. It can
display text or icon. These are passive controls that do not support any interaction with the
user.
● JButton – JButton class provides the functionality of a push button. JButton allows an
icon of string to be associated with the push button.
● JCheckBox – It is supported by the JCheckBox class. It is a control that is used to turn an
option on or off.
● JComboBox– It is provided through the JComboBox class. It normally displays one entry
and can also display a drop down list that allows a user to select a different entry.
● JTree - It is a component that presents a hierarchical view of data. A user has ability to
expand individual subtrees. These are implemented in Swing by JTree class.
1. It provides more powerful and more flexible components possible in AWT package.
For e.g. JButton can have both image as well as text field associated with it which is
not possible in awt package.
3. Further the Swing components can provide pluggable look and feel, which means
that it is easy to substitute another appearance and behavior for an element.
PRELIMINARY
DESIGN
(User Interface)
FORM LAYOUTS
DATABASE
DESIGN
IMPLEMENTATION
LOGIN
jLabel2 = new javax.swing.JLabel();
jPasswordField1 = new
package Student; javax.swing.JPasswordField();
import java.sql.*; jTextField1 = new javax.swing.JTextField();
import javax.swing.JOptionPane; jButton1 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
public class login extends javax.swing.JFrame {
Connection con;
Statement stmt,smt1; setDefaultCloseOperation(javax.swing.WindowCon
ResultSet rs; stants.EXIT_ON_CLOSE);
java.util.Date dt1; setBackground(new java.awt.Color(255, 255,
255));
public login() { setBounds(new java.awt.Rectangle(80, 60, 0,
initComponents(); 0));
try setCursor(new
{ java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSO
Class .forName("com.mysql.jdbc.Driver"); R));
con =
DriverManager.getConnection("jdbc:mysql://local org.jdesktop.beansbinding.Binding binding =
host:3306/studentsystem","root","root"); org.jdesktop.beansbinding.Bindings.createAutoBin
} ding(org.jdesktop.beansbinding.AutoBinding.Upda
catch(Exception e) teStrategy.READ, this,
{ org.jdesktop.beansbinding.ELProperty.create("Sch
System.out.println(e.getMessage()); ool Management System || www.ezindagi.in ||"),
} this,
} org.jdesktop.beansbinding.BeanProperty.create("ti
tle"));
@SuppressWarnings("unchecked") bindingGroup.addBinding(binding);
// <editor-fold defaultstate="collapsed"
desc="Generated Code"> jLabel3.setFont(new java.awt.Font("Tahoma",
private void initComponents() { 1, 18));
bindingGroup = new jLabel3.setForeground(new java.awt.Color(51,
org.jdesktop.beansbinding.BindingGroup(); 0, 0));
jLabel3.setText("Password");
jLabel3 = new javax.swing.JLabel();
.addGroup(layout.createParallelGroup(jav
jLabel2.setFont(new java.awt.Font("Tahoma", ax.swing.GroupLayout.Alignment.LEADING, false)
1, 18)); .addComponent(jPasswordField1)
jLabel2.setForeground(new java.awt.Color(51, .addComponent(jTextField1,
0, 0)); javax.swing.GroupLayout.PREFERRED_SIZE, 180,
jLabel2.setText("User Id"); javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(105, 105, 105))
jPasswordField1.setFont(new .addGroup(layout.createSequentialGroup()
java.awt.Font("Tahoma", 1, 14)); .addGap(178, 178, 178)
jPasswordField1.setForeground(new .addComponent(jButton1,
java.awt.Color(102, 0, 0)); javax.swing.GroupLayout.PREFERRED_SIZE, 233,
javax.swing.GroupLayout.PREFERRED_SIZE)
jTextField1.setFont(new .addContainerGap(168,
java.awt.Font("Tahoma", 1, 12)); Short.MAX_VALUE))
jTextField1.setForeground(new .addGroup(layout.createSequentialGroup()
java.awt.Color(102, 0, 0)); .addContainerGap()
.addComponent(jLabel4,
jButton1.setBackground(new javax.swing.GroupLayout.PREFERRED_SIZE, 559,
java.awt.Color(204, 204, 255)); javax.swing.GroupLayout.PREFERRED_SIZE)
jButton1.setFont(new .addContainerGap(javax.swing.GroupLayo
java.awt.Font("Tahoma", 1, 18)); // NOI18N ut.DEFAULT_SIZE, Short.MAX_VALUE))
jButton1.setForeground(new );
java.awt.Color(51, 0, 0)); layout.setVerticalGroup(
jButton1.setText("Login");
jButton1.addActionListener(new layout.createParallelGroup(javax.swing.GroupLayo
java.awt.event.ActionListener() { ut.Alignment.LEADING)
public void .addGroup(layout.createSequentialGroup()
actionPerformed(java.awt.event.ActionEvent evt) { .addGap(40, 40, 40)
jButton1ActionPerformed(evt); .addComponent(jLabel4)
} .addGap(35, 35, 35)
}); .addGroup(layout.createParallelGroup(jav
ax.swing.GroupLayout.Alignment.TRAILING)
jLabel4.setFont(new java.awt.Font("Tahoma", .addComponent(jLabel2)
3, 36)); .addComponent(jTextField1,
jLabel4.setForeground(new javax.swing.GroupLayout.PREFERRED_SIZE, 24,
java.awt.Color(102, 102, 255)); javax.swing.GroupLayout.PREFERRED_SIZE))
jLabel4.setText(" School Management .addGap(39, 39, 39)
System"); .addGroup(layout.createParallelGroup(jav
ax.swing.GroupLayout.Alignment.TRAILING)
javax.swing.GroupLayout layout = new .addComponent(jLabel3)
javax.swing.GroupLayout(getContentPane()); .addComponent(jPasswordField1,
getContentPane().setLayout(layout); javax.swing.GroupLayout.PREFERRED_SIZE, 24,
layout.setHorizontalGroup( javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyl
layout.createParallelGroup(javax.swing.GroupLayo e.ComponentPlacement.RELATED, 38,
ut.Alignment.LEADING) Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup() .addComponent(jButton1,
.addContainerGap(144, javax.swing.GroupLayout.PREFERRED_SIZE, 53,
Short.MAX_VALUE) javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(jav .addGap(32, 32, 32))
ax.swing.GroupLayout.Alignment.LEADING) );
.addComponent(jLabel3)
.addComponent(jLabel2, bindingGroup.bind();
javax.swing.GroupLayout.PREFERRED_SIZE, 146,
javax.swing.GroupLayout.PREFERRED_SIZE)) java.awt.Dimension screenSize =
.addPreferredGap(javax.swing.LayoutStyl java.awt.Toolkit.getDefaultToolkit().getScreenSize(
e.ComponentPlacement.RELATED) );
setBounds((screenSize.width-595)/2, if ("THEME
(screenSize.height-367)/2, 595, 367); NAME".equals(info.getName())) {
}// </editor-fold>
javax.swing.UIManager.setLookAndFeel(info.getCl
private void assName());
jButton1ActionPerformed(java.awt.event.ActionEv break;
ent evt) { }
}
} catch (ClassNotFoundException ex) {
try{
int flag=0; java.util.logging.Logger.getLogger(login.class.getN
String sql="Select * from login;"; ame()).log(java.util.logging.Level.SEVERE, null, ex);
smt1=con.createStatement(); } catch (InstantiationException ex) {
rs=smt1.executeQuery(sql);
String log=jTextField1.getText(); java.util.logging.Logger.getLogger(login.class.getN
String pass =new ame()).log(java.util.logging.Level.SEVERE, null, ex);
String(jPasswordField1.getPassword()); } catch (IllegalAccessException ex) {
while(rs.next()) {
if(log.equals(rs.getString(1)) &&
java.util.logging.Logger.getLogger(login.class.getN
pass.equals(rs.getString(2))) {
ame()).log(java.util.logging.Level.SEVERE, null, ex);
flag=1;
} catch
break;
(javax.swing.UnsupportedLookAndFeelException
}
ex) {
}
if(flag==1) {
new menu ().setVisible(true); java.util.logging.Logger.getLogger(login.class.getN
dispose(); ame()).log(java.util.logging.Level.SEVERE, null, ex);
} else { }
JOptionPane.showMessageDialog(this, //</editor-fold>
"Please check user name / password", "Error
Occured !",JOptionPane.ERROR_MESSAGE); java.awt.EventQueue.invokeLater(new
} Runnable() {
} catch(Exception ex){ @Override
} public void run() {
new login().setVisible(true);
}
} });
}
bindingGroup.bind(); System.exit(0);
// TODO add your handling code here:
java.awt.Dimension screenSize = }
java.awt.Toolkit.getDefaultToolkit().getScreenSize(
); private void
setBounds((screenSize.width-707)/2, jButton5ActionPerformed(java.awt.event.ActionEv
(screenSize.height-560)/2, 707, 560); ent evt) {
}// </editor-fold> // TODO add your handling code here:
Class.forName("com.mysql.jdbc.Driver").newInsta
nce();
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://local
host:3306/school","root","root");
// Create SQL statement and execute query.
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
jTextField4.setFont(new layout.createParallelGroup(javax.swing.GroupLayo
java.awt.Font("Tahoma", 1, 14)); ut.Alignment.LEADING)
jTextField4.setForeground(new .addGroup(layout.createSequentialGroup()
java.awt.Color(51, 0, 0)); .addGroup(layout.createParallelGroup(jav
ax.swing.GroupLayout.Alignment.LEADING)
jTextField4.setBorder(javax.swing.BorderFactory.cr .addGroup(layout.createSequentialGro
eateEtchedBorder()); up()
.addGap(57, 57, 57)
jTextField3.setFont(new .addComponent(jLabel6,
java.awt.Font("Tahoma", 1, 14)); javax.swing.GroupLayout.PREFERRED_SIZE, 559,
jTextField3.setForeground(new javax.swing.GroupLayout.PREFERRED_SIZE))
java.awt.Color(51, 0, 0)); .addGroup(layout.createSequentialGro
up()
jTextField3.setBorder(javax.swing.BorderFactory.cr .addContainerGap()
eateEtchedBorder()); .addGroup(layout.createParallelGrou
p(javax.swing.GroupLayout.Alignment.LEADING)
jTextField2.setFont(new .addGroup(layout.createSequential
java.awt.Font("Tahoma", 1, 14)); Group()
jTextField2.setForeground(new .addGap(87, 87, 87)
java.awt.Color(51, 0, 0));
.addComponent(cmdFirst, .addComponent(jLabel15)
javax.swing.GroupLayout.PREFERRED_SIZE, 66, .addComponent(jLabel12)
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel13)
.addGap(28, 28, 28) .addComponent(jLabel11)
.addComponent(cmdNext, .addComponent(jLabel10))
javax.swing.GroupLayout.PREFERRED_SIZE, 64, .addPreferredGap(javax.swing.La
javax.swing.GroupLayout.PREFERRED_SIZE) youtStyle.ComponentPlacement.UNRELATED)
.addGap(31, 31, 31) .addGroup(layout.createParallel
.addComponent(cmdPrev) Group(javax.swing.GroupLayout.Alignment.LEADIN
.addGap(29, 29, 29) G, false)
.addComponent(cmdLast, .addComponent(jTextField9)
javax.swing.GroupLayout.PREFERRED_SIZE, 65, .addComponent(jTextField8)
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jTextField7)
.addGap(37, 37, 37) .addComponent(jTextField6)
.addComponent(cmdExit, .addComponent(jTextField5,
javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE, 187,
javax.swing.GroupLayout.PREFERRED_SIZE)) javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGroup(layout.createSequential .addContainerGap(javax.swing.GroupLayo
Group() ut.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createParallel );
Group(javax.swing.GroupLayout.Alignment.TRAILI layout.setVerticalGroup(
NG)
.addGroup(layout.createSeque layout.createParallelGroup(javax.swing.GroupLayo
ntialGroup() ut.Alignment.LEADING)
.addGroup(layout.createPar .addGroup(layout.createSequentialGroup()
allelGroup(javax.swing.GroupLayout.Alignment.TR .addGap(11, 11, 11)
AILING) .addComponent(jLabel6)
.addComponent(jLabel18) .addGap(37, 37, 37)
.addComponent(jLabel17) .addGroup(layout.createParallelGroup(jav
.addComponent(jLabel16) ax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel14) .addGroup(layout.createSequentialGro
) up()
.addPreferredGap(javax.swi .addGap(2, 2, 2)
ng.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGrou
.addGroup(layout.createPar p(javax.swing.GroupLayout.Alignment.BASELINE)
allelGroup(javax.swing.GroupLayout.Alignment.LE .addComponent(jLabel19)
ADING, false) .addComponent(jTextField10,
.addComponent(jTextField javax.swing.GroupLayout.PREFERRED_SIZE,
4) javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(jTextField javax.swing.GroupLayout.PREFERRED_SIZE))
3) .addPreferredGap(javax.swing.Layout
.addComponent(jTextField Style.ComponentPlacement.RELATED)
2) .addGroup(layout.createParallelGrou
.addComponent(jTextField p(javax.swing.GroupLayout.Alignment.BASELINE)
1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, .addComponent(jLabel18)
javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(jTextField1,
.addGroup(layout.createSeque javax.swing.GroupLayout.PREFERRED_SIZE,
ntialGroup() javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(jLabel19) javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swi .addGap(10, 10, 10)
ng.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGrou
.addComponent(jTextField1 p(javax.swing.GroupLayout.Alignment.BASELINE)
0, javax.swing.GroupLayout.PREFERRED_SIZE, 187, .addComponent(jLabel17)
javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(jTextField2,
.addGap(18, 18, 18) javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(layout.createParallel javax.swing.GroupLayout.DEFAULT_SIZE,
Group(javax.swing.GroupLayout.Alignment.TRAILI javax.swing.GroupLayout.PREFERRED_SIZE))
NG) .addGap(10, 10, 10)
.addGroup(layout.createParallelGrou .addGroup(layout.createParallelGroup(jav
p(javax.swing.GroupLayout.Alignment.BASELINE) ax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel16) .addComponent(cmdPrev,
.addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 34,
javax.swing.GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
javax.swing.GroupLayout.DEFAULT_SIZE, .addComponent(cmdExit,
javax.swing.GroupLayout.PREFERRED_SIZE)) javax.swing.GroupLayout.DEFAULT_SIZE, 34,
.addGap(10, 10, 10) Short.MAX_VALUE)
.addGroup(layout.createParallelGrou .addComponent(cmdLast,
p(javax.swing.GroupLayout.Alignment.BASELINE) javax.swing.GroupLayout.DEFAULT_SIZE, 34,
.addComponent(jLabel14) Short.MAX_VALUE)
.addComponent(jTextField4, .addComponent(cmdNext,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 34,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(cmdFirst,
.addGroup(layout.createSequentialGro javax.swing.GroupLayout.DEFAULT_SIZE, 34,
up() Short.MAX_VALUE))
.addGroup(layout.createParallelGrou .addGap(19, 19, 19))
p(javax.swing.GroupLayout.Alignment.BASELINE) );
.addComponent(jLabel15)
.addComponent(jTextField5, bindingGroup.bind();
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, java.awt.Dimension screenSize =
javax.swing.GroupLayout.PREFERRED_SIZE)) java.awt.Toolkit.getDefaultToolkit().getScreenSize(
.addGap(10, 10, 10) );
.addGroup(layout.createParallelGrou setBounds((screenSize.width-677)/2,
p(javax.swing.GroupLayout.Alignment.BASELINE) (screenSize.height-366)/2, 677, 366);
.addComponent(jLabel12) }// </editor-fold>
.addComponent(jTextField6, // Global variables
javax.swing.GroupLayout.PREFERRED_SIZE, Statement stmt = null;
javax.swing.GroupLayout.DEFAULT_SIZE, ResultSet rs = null;
javax.swing.GroupLayout.PREFERRED_SIZE)) String SQL = "SELECT * FROM Student";
.addGap(10, 10, 10) public void disable_textfields() {
.addGroup(layout.createParallelGrou
p(javax.swing.GroupLayout.Alignment.BASELINE) jTextField1.setEditable(false);
.addComponent(jLabel13) jTextField2.setEditable(false);
.addComponent(jTextField7, jTextField3.setEditable(false);
javax.swing.GroupLayout.PREFERRED_SIZE, jTextField4.setEditable(false);
javax.swing.GroupLayout.DEFAULT_SIZE, jTextField5.setEditable(false);
javax.swing.GroupLayout.PREFERRED_SIZE)) jTextField6.setEditable(false);
.addGap(10, 10, 10) jTextField7.setEditable(false);
.addGroup(layout.createParallelGrou jTextField8.setEditable(false);
p(javax.swing.GroupLayout.Alignment.BASELINE) jTextField9.setEditable(false);
.addComponent(jLabel11) jTextField10.setEditable(false);
.addComponent(jTextField8,
javax.swing.GroupLayout.PREFERRED_SIZE, }
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) private void
.addGap(10, 10, 10) cmdFirstActionPerformed(java.awt.event.ActionEv
.addGroup(layout.createParallelGrou ent evt) {
p(javax.swing.GroupLayout.Alignment.BASELINE) try {
.addComponent(jLabel10) Class.forName("com.mysql.jdbc.Driver");
.addComponent(jTextField9, Connection con = (Connection)
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, DriverManager.getConnection("jdbc:mysql://local
javax.swing.GroupLayout.PREFERRED_SIZE)))) host:3306/school","root","root");
.addGap(38, 38, 38) if (rs.first()) {
String admno = rs.getString("admno");
String name = rs.getString("name"); String contact = rs.getString("contact");
String std = rs.getString("standard"); // Displaying the contents in respective
String rollno = rs.getString("rollno"); text boxes.
String fname = rs.getString("fname"); jTextField1.setText(name);
String mname = rs.getString("mname"); jTextField2.setText(std);
String address = rs.getString("address"); jTextField3.setText(rollno);
String city = rs.getString("city"); jTextField4.setText(fname);
String religion = rs.getString("religion"); jTextField5.setText(mname);
String contact = rs.getString("contact"); jTextField6.setText(address);
// Displaying the contents in respective jTextField7.setText(city);
text boxes. jTextField8.setText(religion);
jTextField1.setText(name); jTextField9.setText(contact);
jTextField2.setText(std); jTextField10.setText(admno);
jTextField3.setText(rollno); cmdFirst.setEnabled(true);
jTextField4.setText(fname); cmdNext.setEnabled(true);
jTextField5.setText(mname); cmdPrev.setEnabled(true);
jTextField6.setText(address); cmdLast.setEnabled(true);
jTextField7.setText(city); } else {
jTextField8.setText(religion); cmdNext.setEnabled(false);
jTextField9.setText(contact); JOptionPane.showMessageDialog(this,
jTextField10.setText(admno); "You are at Last Record position", "Student",0);
cmdFirst.setEnabled(false); }
cmdNext.setEnabled(true); } catch (Exception e) {
cmdPrev.setEnabled(false); JOptionPane.showMessageDialog(this,
cmdLast.setEnabled(true); e.getMessage());
} else { }
cmdFirst.setEnabled(false); }
cmdNext.setEnabled(false);
cmdPrev.setEnabled(false); private void
cmdLast.setEnabled(false); cmdExitActionPerformed(java.awt.event.ActionEv
JOptionPane.showMessageDialog(this, ent evt) {
"There is no Record in Table", "Student",0); new menu ().setVisible(true);
} dispose();
} catch (Exception e) { }
JOptionPane.showMessageDialog(this,
e.getMessage()); private void
} cmdPrevActionPerformed(java.awt.event.ActionEv
} ent evt) {
try {
private void Class.forName("com.mysql.jdbc.Driver");
cmdNextActionPerformed(java.awt.event.ActionEv Connection con = (Connection)
ent evt) {
try { DriverManager.getConnection("jdbc:mysql://local
Class.forName("com.mysql.jdbc.Driver"); host:3306/School","root","root");
Connection con = (Connection) if (rs.previous()) {
String admno = rs.getString("admno");
DriverManager.getConnection("jdbc:mysql://local String name = rs.getString("name");
host:3306/School","root","root"); String std = rs.getString("standard");
if (rs.next()) { String rollno = rs.getString("rollno");
String admno = rs.getString("admno"); String fname = rs.getString("fname");
String name = rs.getString("name"); String mname = rs.getString("mname");
String std = rs.getString("standard"); String address = rs.getString("address");
String rollno = rs.getString("rollno"); String city = rs.getString("city");
String fname = rs.getString("fname"); String religion = rs.getString("religion");
String mname = rs.getString("mname"); String contact = rs.getString("contact");
String address = rs.getString("address"); // Displaying the contents in respective
String city = rs.getString("city"); text boxes.
String religion = rs.getString("religion"); jTextField1.setText(name);
jTextField2.setText(std); cmdPrev.setEnabled(true);
jTextField3.setText(rollno); cmdLast.setEnabled(false);
jTextField4.setText(fname); } else {
jTextField5.setText(mname); JOptionPane.showMessageDialog(this,
jTextField6.setText(address); "You are Already at Last Record", "Student",0);
jTextField7.setText(city); }
jTextField8.setText(religion); } catch (Exception e) {
jTextField9.setText(contact); JOptionPane.showMessageDialog(this,
jTextField10.setText(admno); e.getMessage());
cmdFirst.setEnabled(true); }
cmdNext.setEnabled(true); }
cmdPrev.setEnabled(true);
cmdLast.setEnabled(true); private void
} else { formWindowGainedFocus(java.awt.event.Window
cmdPrev.setEnabled(false); Event evt) {
JOptionPane.showMessageDialog(this, disable_textfields();
"You are at First Position", "Student",0); try {
} // Connect to MySQL database
} catch (Exception e) { // Don't forget to import the two packages
JOptionPane.showMessageDialog(this, // import java.sql.*;
e.getMessage()); // import javax.swing.JOptionPane;
} Class.forName("com.mysql.jdbc.Driver");
} Connection con = (Connection)
}UPDATE
package Student; }
import java.sql.*;
import javax.swing.JOptionPane; /** This method is called from within the
import javax.swing.DefaultListModel; constructor to
* initialize the form.
public class update extends javax.swing.JFrame { * WARNING: Do NOT modify this code. The
content of this method is
/** Creates new form update */ * always regenerated by the Form Editor.
public update() { */
initComponents(); @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed"
desc="Generated Code"> addWindowFocusListener(new
private void initComponents() { java.awt.event.WindowFocusListener() {
bindingGroup = new public void
org.jdesktop.beansbinding.BindingGroup(); windowGainedFocus(java.awt.event.WindowEvent
evt) {
cmdExit = new javax.swing.JButton(); formWindowGainedFocus(evt);
jSeparator2 = new javax.swing.JSeparator(); }
cmdUpdate = new javax.swing.JButton(); public void
jScrollPane1 = new javax.swing.JScrollPane(); windowLostFocus(java.awt.event.WindowEvent
jList1 = new javax.swing.JList(); evt) {
jLabel6 = new javax.swing.JLabel(); }
jLabel10 = new javax.swing.JLabel(); });
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel(); cmdExit.setBackground(new
jLabel13 = new javax.swing.JLabel(); java.awt.Color(204, 204, 255));
jLabel14 = new javax.swing.JLabel(); cmdExit.setFont(new
jLabel15 = new javax.swing.JLabel(); java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel16 = new javax.swing.JLabel(); cmdExit.setText("Clear");
jLabel17 = new javax.swing.JLabel(); cmdExit.addActionListener(new
jLabel18 = new javax.swing.JLabel(); java.awt.event.ActionListener() {
jTextField9 = new javax.swing.JTextField(); public void
jTextField3 = new javax.swing.JTextField(); actionPerformed(java.awt.event.ActionEvent evt) {
jTextField4 = new javax.swing.JTextField(); cmdExitActionPerformed(evt);
jTextField2 = new javax.swing.JTextField(); }
jTextField1 = new javax.swing.JTextField(); });
jTextField8 = new javax.swing.JTextField();
jTextField6 = new javax.swing.JTextField(); cmdUpdate.setBackground(new
jTextField5 = new javax.swing.JTextField(); java.awt.Color(204, 204, 255));
jTextField7 = new javax.swing.JTextField(); cmdUpdate.setFont(new
jTextField10 = new javax.swing.JTextField(); java.awt.Font("Tahoma", 1, 14));
jLabel19 = new javax.swing.JLabel(); cmdUpdate.setText("Update");
jLabel2 = new javax.swing.JLabel(); cmdUpdate.addActionListener(new
cmdExit1 = new javax.swing.JButton(); java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
setDefaultCloseOperation(javax.swing.WindowCon cmdUpdateActionPerformed(evt);
stants.EXIT_ON_CLOSE); }
setBounds(new java.awt.Rectangle(200, 70, 0, });
0));
jList1.setModel(new DefaultListModel());
org.jdesktop.beansbinding.Binding binding = jList1.addMouseListener(new
org.jdesktop.beansbinding.Bindings.createAutoBin java.awt.event.MouseAdapter() {
ding(org.jdesktop.beansbinding.AutoBinding.Upda public void
teStrategy.READ_WRITE, this, mouseClicked(java.awt.event.MouseEvent evt) {
org.jdesktop.beansbinding.ELProperty.create("Sch jList1MouseClicked(evt);
ool Management System || www.ezindagi.in ||"), }
this, });
org.jdesktop.beansbinding.BeanProperty.create("ti jScrollPane1.setViewportView(jList1);
tle"));
bindingGroup.addBinding(binding);
jLabel6.setFont(new jLabel17.setForeground(new
java.awt.Font("Helvetica", 1, 15)); java.awt.Color(51, 0, 0));
jLabel17.setText("Class : ");
jLabel6.setHorizontalAlignment(javax.swing.Swing
Constants.CENTER); jLabel18.setFont(new java.awt.Font("Arial", 1,
jLabel6.setText("Select a Student"); 14));
jLabel18.setForeground(new
jLabel10.setFont(new java.awt.Font("Arial", 1, java.awt.Color(51, 0, 0));
14)); jLabel18.setText("Name : ");
jLabel10.setForeground(new
java.awt.Color(51, 0, 0)); jTextField9.setFont(new
jLabel10.setText("Contact No. : "); java.awt.Font("Tahoma", 1, 14));
jTextField9.setForeground(new
jLabel11.setFont(new java.awt.Font("Arial", 1, java.awt.Color(51, 0, 0));
14));
jLabel11.setForeground(new jTextField9.setBorder(javax.swing.BorderFactory.cr
java.awt.Color(51, 0, 0)); eateEtchedBorder());
jLabel11.setText("Religion : ");
jTextField3.setFont(new
jLabel12.setFont(new java.awt.Font("Arial", 1, java.awt.Font("Tahoma", 1, 14));
14)); jTextField3.setForeground(new
jLabel12.setForeground(new java.awt.Color(51, 0, 0));
java.awt.Color(51, 0, 0));
jLabel12.setText("Local Address : "); jTextField3.setBorder(javax.swing.BorderFactory.cr
eateEtchedBorder());
jLabel13.setFont(new java.awt.Font("Arial", 1,
14)); jTextField4.setFont(new
jLabel13.setForeground(new
java.awt.Color(51, 0, 0));
jLabel13.setText("City / District : "); java.awt.Font("Tahoma", 1, 14));
jTextField4.setForeground(new
jLabel14.setFont(new java.awt.Font("Arial", 1, java.awt.Color(51, 0, 0));
14));
jLabel14.setForeground(new jTextField4.setBorder(javax.swing.BorderFactory.cr
java.awt.Color(51, 0, 0)); eateEtchedBorder());
jLabel14.setText("Father's Name : ");
jTextField2.setFont(new
jLabel15.setFont(new java.awt.Font("Arial", 1, java.awt.Font("Tahoma", 1, 14));
14)); jTextField2.setForeground(new
jLabel15.setForeground(new java.awt.Color(51, 0, 0));
java.awt.Color(51, 0, 0));
jLabel15.setText("Mother's Name : "); jTextField2.setBorder(javax.swing.BorderFactory.cr
eateEtchedBorder());
jLabel16.setFont(new java.awt.Font("Arial", 1,
14)); jTextField1.setFont(new
jLabel16.setForeground(new java.awt.Font("Tahoma", 1, 14));
java.awt.Color(51, 0, 0)); jTextField1.setForeground(new
jLabel16.setText("Roll No. : "); java.awt.Color(51, 0, 0));
jLabel17.setFont(new java.awt.Font("Arial", 1,
14));
jLabel19.setText("Admission No : ");
jTextField1.setBorder(javax.swing.BorderFactory.cr
eateEtchedBorder()); jLabel2.setFont(new java.awt.Font("Tahoma",
3, 36)); // NOI18N
jTextField8.setFont(new jLabel2.setForeground(new
java.awt.Font("Tahoma", 1, 14)); java.awt.Color(102, 102, 255));
jTextField8.setForeground(new jLabel2.setText(" School Management
java.awt.Color(51, 0, 0)); System");
jTextField8.setBorder(javax.swing.BorderFactory.cr cmdExit1.setBackground(new
eateEtchedBorder()); java.awt.Color(204, 204, 255));
cmdExit1.setFont(new
jTextField6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
java.awt.Font("Tahoma", 1, 14)); cmdExit1.setText("Exit");
jTextField6.setForeground(new cmdExit1.addActionListener(new
java.awt.Color(51, 0, 0)); java.awt.event.ActionListener() {
public void
jTextField6.setBorder(javax.swing.BorderFactory.cr actionPerformed(java.awt.event.ActionEvent evt) {
eateEtchedBorder()); cmdExit1ActionPerformed(evt);
}
jTextField5.setFont(new });
java.awt.Font("Tahoma", 1, 14));
jTextField5.setForeground(new javax.swing.GroupLayout layout = new
java.awt.Color(51, 0, 0)); javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
jTextField5.setBorder(javax.swing.BorderFactory.cr
eateEtchedBorder());
layout.createParallelGroup(javax.swing.GroupLayo
jTextField7.setFont(new ut.Alignment.LEADING)
java.awt.Font("Tahoma", 1, 14)); .addGroup(layout.createSequentialGroup()
jTextField7.setForeground(new .addGap(25, 25, 25)
java.awt.Color(51, 0, 0)); .addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE, 559,
javax.swing.GroupLayout.PREFERRED_SIZE)
jTextField7.setBorder(javax.swing.BorderFactory.cr
.addContainerGap(46,
eateEtchedBorder());
Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignm
jTextField10.setFont(new
ent.TRAILING, layout.createSequentialGroup()
java.awt.Font("Tahoma", 1, 14));
.addContainerGap(37, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(jav
ax.swing.GroupLayout.Alignment.LEADING)
jTextField10.setForeground(new
.addGroup(layout.createSequentialGro
java.awt.Color(51, 0, 0));
up()
.addGroup(layout.createParallelGrou
jTextField10.setBorder(javax.swing.BorderFactory.
p(javax.swing.GroupLayout.Alignment.LEADING)
createEtchedBorder());
.addGroup(layout.createSequential
Group()
jLabel19.setFont(new java.awt.Font("Arial", 1,
.addGap(15, 15, 15)
14));
.addComponent(jScrollPane1,
jLabel19.setForeground(new
javax.swing.GroupLayout.PREFERRED_SIZE, 171,
java.awt.Color(51, 0, 0));
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequential .addComponent(jSeparator2,
Group() javax.swing.GroupLayout.PREFERRED_SIZE, 570,
.addGap(32, 32, 32) javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6, .addGroup(javax.swing.GroupLayout.Ali
javax.swing.GroupLayout.PREFERRED_SIZE, 140, gnment.TRAILING, layout.createSequentialGroup()
javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.Layout
.addGap(34, 34, 34) Style.ComponentPlacement.RELATED, 110,
.addGroup(layout.createParallelGrou javax.swing.GroupLayout.PREFERRED_SIZE)
p(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(cmdUpdate,
.addGroup(layout.createSequential javax.swing.GroupLayout.PREFERRED_SIZE, 116,
Group() javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallel .addGap(27, 27, 27)
Group(javax.swing.GroupLayout.Alignment.TRAILI .addComponent(cmdExit,
NG) javax.swing.GroupLayout.PREFERRED_SIZE, 97,
.addComponent(jLabel18) javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel17) .addGap(29, 29, 29)
.addComponent(jLabel16) .addComponent(cmdExit1,
.addComponent(jLabel14) javax.swing.GroupLayout.PREFERRED_SIZE, 78,
.addComponent(jLabel15) javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12) .addGap(113, 113, 113)))
.addComponent(jLabel13) .addGap(23, 23, 23))
.addComponent(jLabel11) );
.addComponent(jLabel10)) layout.setVerticalGroup(
.addPreferredGap(javax.swing.La
youtStyle.ComponentPlacement.UNRELATED) layout.createParallelGroup(javax.swing.GroupLayo
.addGroup(layout.createParallel ut.Alignment.LEADING)
Group(javax.swing.GroupLayout.Alignment.LEADIN .addGroup(layout.createSequentialGroup()
G, false) .addContainerGap()
.addComponent(jTextField9) .addComponent(jLabel2)
.addComponent(jTextField8) .addGap(26, 26, 26)
.addComponent(jTextField7) .addGroup(layout.createParallelGroup(jav
.addComponent(jTextField6) ax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField5) .addGroup(layout.createSequentialGro
up()
.addGroup(layout.createParallelGrou
.addComponent(jTextField4) p(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField3) .addComponent(jLabel19)
.addComponent(jTextField2) .addComponent(jTextField10,
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))) javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequential .addPreferredGap(javax.swing.Layout
Group() Style.ComponentPlacement.RELATED)
.addComponent(jLabel19) .addGroup(layout.createParallelGrou
.addPreferredGap(javax.swing.La p(javax.swing.GroupLayout.Alignment.BASELINE)
youtStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel18)
.addComponent(jTextField10, .addComponent(jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))) javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(10, 10, 10)
.addGroup(layout.createParallelGrou .addComponent(jLabel11)
p(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextField8,
.addComponent(jLabel17) javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(jTextField2,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(10, 10, 10)
.addGap(10, 10, 10) .addGroup(layout.createParallelGrou
.addGroup(layout.createParallelGrou p(javax.swing.GroupLayout.Alignment.BASELINE)
p(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel10)
.addComponent(jLabel16) .addComponent(jTextField9,
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGro
.addGap(10, 10, 10) up()
.addGroup(layout.createParallelGrou .addGap(12, 12, 12)
p(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6)
.addComponent(jLabel14) .addPreferredGap(javax.swing.Layout
.addComponent(jTextField4, Style.ComponentPlacement.RELATED)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE, 255,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(27, 27, 27)
.addGap(10, 10, 10) .addComponent(jSeparator2,
.addGroup(layout.createParallelGrou javax.swing.GroupLayout.PREFERRED_SIZE, 21,
p(javax.swing.GroupLayout.Alignment.BASELINE) javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel15) .addPreferredGap(javax.swing.LayoutStyl
.addComponent(jTextField5, e.ComponentPlacement.RELATED)
javax.swing.GroupLayout.PREFERRED_SIZE, .addGroup(layout.createParallelGroup(jav
javax.swing.GroupLayout.DEFAULT_SIZE, ax.swing.GroupLayout.Alignment.LEADING)
javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(j
.addGap(10, 10, 10) avax.swing.GroupLayout.Alignment.BASELINE)
.addGroup(layout.createParallelGrou .addComponent(cmdExit,
p(javax.swing.GroupLayout.Alignment.BASELINE) javax.swing.GroupLayout.DEFAULT_SIZE, 38,
.addComponent(jLabel12) Short.MAX_VALUE)
.addComponent(jTextField6, .addComponent(cmdExit1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 38,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(cmdUpdate,
.addGap(10, 10, 10) javax.swing.GroupLayout.DEFAULT_SIZE, 38,
.addGroup(layout.createParallelGrou Short.MAX_VALUE))
p(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel13)
.addComponent(jTextField7, .addGap(21, 21, 21))
javax.swing.GroupLayout.PREFERRED_SIZE, );
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) bindingGroup.bind();
.addGap(10, 10, 10)
.addGroup(layout.createParallelGrou
p(javax.swing.GroupLayout.Alignment.BASELINE)
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize(
); String address = jTextField6.getText();
setBounds((screenSize.width-646)/2, String city = jTextField7.getText();
(screenSize.height-528)/2, 646, 528); String religion = jTextField8.getText();
}// </editor-fold> String contact = jTextField9.getText();
Statement stmt = null;
ResultSet rs = null;
String SQL = "SELECT * FROM Student"; String strSQL = "Update student set name
='"+(name)+"', standard = '"+(standard)+"', rollno =
private void '"+(rollno)+"', fname = '"+(fname)+"', mname = '"+
cmdExitActionPerformed(java.awt.event.ActionEv (mname)+"', address = '"+(address)+"', city = '"+
ent evt) { (city)+"', religion = '"+(religion)+"', contact =
JOptionPane.showMessageDialog(this,e.getMessa
} else { ge());
JOptionPane.showMessageDialog(null, e.printStackTrace();
"Record does not found in Student table"); }
} }
} catch (Exception e) {
JOptionPane.showMessageDialog(this, private void
e.getMessage()); cmdExit1ActionPerformed(java.awt.event.ActionE
} vent evt) {
} // TODO add your handling code here:
jLabel6.setHorizontalAlignment(javax.swing.Swing jTextField9.setFont(new
Constants.CENTER); java.awt.Font("Tahoma", 1, 14));
jLabel6.setText("Select a Student"); jTextField9.setForeground(new
java.awt.Color(51, 0, 0));
jLabel10.setFont(new java.awt.Font("Arial", 1,
14)); jTextField9.setBorder(javax.swing.BorderFactory.cr
jLabel10.setForeground(new eateEtchedBorder());
java.awt.Color(51, 0, 0));
jLabel10.setText("Contact No. : "); jTextField3.setFont(new
java.awt.Font("Tahoma", 1, 14));
jLabel11.setFont(new java.awt.Font("Arial", 1, jTextField3.setForeground(new
14)); java.awt.Color(51, 0, 0));
jLabel11.setForeground(new
java.awt.Color(51, 0, 0)); jTextField3.setBorder(javax.swing.BorderFactory.cr
jLabel11.setText("Religion : "); eateEtchedBorder());
jTextField6.setBorder(javax.swing.BorderFactory.cr layout.createParallelGroup(javax.swing.GroupLayo
eateEtchedBorder()); ut.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
jTextField5.setFont(new .addGap(33, 33, 33)
java.awt.Font("Tahoma", 1, 14)); .addGroup(layout.createParallelGroup(jav
jTextField5.setForeground(new ax.swing.GroupLayout.Alignment.LEADING, false)
java.awt.Color(51, 0, 0)); .addGroup(layout.createSequentialGro
up()
.addGroup(layout.createParallelGrou
jTextField5.setBorder(javax.swing.BorderFactory.cr
p(javax.swing.GroupLayout.Alignment.LEADING)
eateEtchedBorder());
.addGroup(layout.createSequential
Group()
jTextField7.setFont(new
.addGap(15, 15, 15)
java.awt.Font("Tahoma", 1, 14));
.addComponent(jScrollPane1,
jTextField7.setForeground(new
javax.swing.GroupLayout.PREFERRED_SIZE, 171,
java.awt.Color(51, 0, 0));
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequential
jTextField7.setBorder(javax.swing.BorderFactory.cr Group()
eateEtchedBorder()); .addGap(32, 32, 32)
.addComponent(jLabel6,
jTextField10.setFont(new javax.swing.GroupLayout.PREFERRED_SIZE, 140,
java.awt.Font("Tahoma", 1, 14)); javax.swing.GroupLayout.PREFERRED_SIZE)))
jTextField10.setForeground(new .addGap(34, 34, 34)
java.awt.Color(51, 0, 0)); .addGroup(layout.createParallelGrou
p(javax.swing.GroupLayout.Alignment.TRAILING)
jTextField10.setBorder(javax.swing.BorderFactory. .addGroup(layout.createSequential
createEtchedBorder()); Group()
.addGroup(layout.createParallel
jLabel19.setFont(new java.awt.Font("Arial", 1, Group(javax.swing.GroupLayout.Alignment.TRAILI
14)); NG)
jLabel19.setForeground(new .addComponent(jLabel18)
java.awt.Color(51, 0, 0)); .addComponent(jLabel17)
jLabel19.setText("Admission No : "); .addComponent(jLabel16)
.addComponent(jLabel14) );
.addComponent(jLabel15) layout.setVerticalGroup(
.addComponent(jLabel12)
.addComponent(jLabel13) layout.createParallelGroup(javax.swing.GroupLayo
.addComponent(jLabel11) ut.Alignment.LEADING)
.addComponent(jLabel10)) .addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.La .addContainerGap()
youtStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel2)
.addGroup(layout.createParallel .addGap(28, 28, 28)
Group(javax.swing.GroupLayout.Alignment.LEADIN .addGroup(layout.createParallelGroup(jav
G, false) ax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField9) .addGroup(layout.createSequentialGro
.addComponent(jTextField8) up()
.addComponent(jTextField7) .addGroup(layout.createParallelGrou
.addComponent(jTextField6) p(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField5) .addComponent(jLabel19)
.addComponent(jTextField4) .addComponent(jTextField10,
.addComponent(jTextField3) javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(jTextField2) javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE))
javax.swing.GroupLayout.PREFERRED_SIZE, 187, .addPreferredGap(javax.swing.Layout
javax.swing.GroupLayout.PREFERRED_SIZE))) Style.ComponentPlacement.RELATED)
.addGroup(layout.createSequential .addGroup(layout.createParallelGrou
Group() p(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel19) .addComponent(jLabel18)
.addPreferredGap(javax.swing.La .addComponent(jTextField1,
youtStyle.ComponentPlacement.UNRELATED) javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(jTextField10, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE))
javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGap(10, 10, 10)
.addComponent(jSeparator2, .addGroup(layout.createParallelGrou
javax.swing.GroupLayout.DEFAULT_SIZE, 570, p(javax.swing.GroupLayout.Alignment.BASELINE)
Short.MAX_VALUE)) .addComponent(jLabel17)
.addContainerGap(27, .addComponent(jTextField2,
Short.MAX_VALUE)) javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(javax.swing.GroupLayout.Alignm javax.swing.GroupLayout.DEFAULT_SIZE,
ent.TRAILING, layout.createSequentialGroup() javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(143, .addGap(10, 10, 10)
Short.MAX_VALUE) .addGroup(layout.createParallelGrou
.addComponent(cmdUpdate, p(javax.swing.GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.PREFERRED_SIZE, 116, .addComponent(jLabel16)
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jTextField3,
.addGap(27, 27, 27) javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(cmdExit, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(10, 10, 10)
.addGap(29, 29, 29) .addGroup(layout.createParallelGrou
.addComponent(cmdExit1, p(javax.swing.GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.PREFERRED_SIZE, 78, .addComponent(jLabel14)
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jTextField4,
.addGap(140, 140, 140)) javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(layout.createSequentialGroup() javax.swing.GroupLayout.DEFAULT_SIZE,
.addGap(25, 25, 25) javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel2, .addGap(10, 10, 10)
javax.swing.GroupLayout.PREFERRED_SIZE, 559, .addGroup(layout.createParallelGrou
javax.swing.GroupLayout.PREFERRED_SIZE) p(javax.swing.GroupLayout.Alignment.BASELINE)
.addContainerGap(46, .addComponent(jLabel15)
Short.MAX_VALUE))
.addComponent(jTextField5, .addComponent(cmdExit1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 38,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(cmdUpdate,
.addGap(10, 10, 10) javax.swing.GroupLayout.DEFAULT_SIZE, 38,
.addGroup(layout.createParallelGrou Short.MAX_VALUE))
p(javax.swing.GroupLayout.Alignment.BASELINE) .addGap(19, 19, 19))
.addComponent(jLabel12) );
.addComponent(jTextField6,
javax.swing.GroupLayout.PREFERRED_SIZE, bindingGroup.bind();
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) java.awt.Dimension screenSize =
.addGap(10, 10, 10) java.awt.Toolkit.getDefaultToolkit().getScreenSize(
.addGroup(layout.createParallelGrou );
p(javax.swing.GroupLayout.Alignment.BASELINE) setBounds((screenSize.width-646)/2,
.addComponent(jLabel13) (screenSize.height-528)/2, 646, 528);
.addComponent(jTextField7, }// </editor-fold>
javax.swing.GroupLayout.PREFERRED_SIZE, Statement stmt = null;
javax.swing.GroupLayout.DEFAULT_SIZE, ResultSet rs = null;
javax.swing.GroupLayout.PREFERRED_SIZE)) String SQL = "SELECT * FROM Student";
.addGap(10, 10, 10)
.addGroup(layout.createParallelGrou private void
p(javax.swing.GroupLayout.Alignment.BASELINE) cmdExitActionPerformed(java.awt.event.ActionEv
.addComponent(jLabel11) ent evt) {
.addComponent(jTextField8,
javax.swing.GroupLayout.PREFERRED_SIZE, jTextField1.setText(null);
javax.swing.GroupLayout.DEFAULT_SIZE, jTextField2.setText(null);
javax.swing.GroupLayout.PREFERRED_SIZE)) jTextField3.setText(null);
.addGap(10, 10, 10) jTextField4.setText(null);
.addGroup(layout.createParallelGrou jTextField5.setText(null);
p(javax.swing.GroupLayout.Alignment.BASELINE) jTextField6.setText(null);
.addComponent(jLabel10) jTextField7.setText(null);
.addComponent(jTextField9, jTextField8.setText(null);
javax.swing.GroupLayout.PREFERRED_SIZE, jTextField9.setText(null);
javax.swing.GroupLayout.DEFAULT_SIZE, jTextField10.setText(null);
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGro }
up()
.addGap(12, 12, 12) private void
.addComponent(jLabel6) cmdUpdateActionPerformed(java.awt.event.Actio
.addPreferredGap(javax.swing.Layout nEvent evt) {
Style.ComponentPlacement.RELATED) try {
.addComponent(jScrollPane1, Class.forName("com.mysql.jdbc.Driver");
javax.swing.GroupLayout.PREFERRED_SIZE, 255, Connection con = (Connection)
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(27, 27, 27) DriverManager.getConnection("jdbc:mysql://local
.addComponent(jSeparator2, host:3306/school","root","root");
javax.swing.GroupLayout.PREFERRED_SIZE, 21, stmt = con.createStatement();
javax.swing.GroupLayout.PREFERRED_SIZE) rs = stmt.executeQuery(SQL);
.addPreferredGap(javax.swing.LayoutStyl
e.ComponentPlacement.RELATED) int admno =
.addGroup(layout.createParallelGroup(jav Integer.parseInt(jTextField10.getText());
ax.swing.GroupLayout.Alignment.LEADING) String name = jTextField1.getText();
.addGroup(layout.createParallelGroup(j String standard = jTextField2.getText();
avax.swing.GroupLayout.Alignment.BASELINE) String rollno = jTextField3.getText();
.addComponent(cmdExit, String fname = jTextField4.getText();
javax.swing.GroupLayout.DEFAULT_SIZE, 38, String mname = jTextField5.getText();
Short.MAX_VALUE) String address = jTextField6.getText();
String city = jTextField7.getText();
String religion = jTextField8.getText(); // Displaying the contents in respective text
String contact = jTextField9.getText(); boxes.
jTextField10.setText(""+adm);
jTextField1.setText(name);
String strSQL = "Delete from student where jTextField2.setText(standard);
admno = " + (admno); jTextField3.setText(rollno);
int rowsEffected = jTextField4.setText(fname);
stmt.executeUpdate(strSQL); jTextField5.setText(mname);
if (rowsEffected == 0) jTextField6.setText(address);
JOptionPane.showMessageDialog(this, jTextField7.setText(city);
"Record does not exists"); jTextField8.setText(religion);
else jTextField9.setText(contact);
JOptionPane.showMessageDialog(this,"Record
Deleted Sucessfully"); } else {
} catch (Exception e) { JOptionPane.showMessageDialog(null,
JOptionPane.showMessageDialog(this, "Record does not found in Student table");
e.getMessage()); }
} } catch (Exception e) {
} JOptionPane.showMessageDialog(this,
e.getMessage());
private void }
jList1MouseClicked(java.awt.event.MouseEvent }
evt) {
// getSelectedValue() method extracts the private void
current cursor location value into a variable formWindowGainedFocus(java.awt.event.Window
String admno = (String) Event evt) {
jList1.getSelectedValue(); jTextField10.setEditable(false);
// Extract the first 4 characters as Member No // Creating a ListModel object dModel to
into a variable perform DefaultListModel
String Mno =admno.trim().substring(0, 2); // method operations
String query = "SELECT * FROM Student DefaultListModel dModel = (DefaultListModel)
WHERE admno = " + (Mno) + ";"; jList1.getModel();
try { // Method to add elements into jList1 control
dModel.clear();
Class.forName("com.mysql.jdbc.Driver").newInsta try {
nce(); Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection) Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://local
host:3306/school","root","root"); DriverManager.getConnection("jdbc:mysql://local
// Create SQL statement and execute query. host:3306/school","root","root");
stmt = con.createStatement(); stmt = con.createStatement();
rs = stmt.executeQuery(query); rs = stmt.executeQuery(SQL);
while (rs.next()) {
if (rs.next()) { String Mno = rs.getString("admno");
int adm = rs.getInt("admno"); String Mna = rs.getString("name");
String name = rs.getString("name"); // To make the Member no. as 4 digit
String standard = rs.getString("standard"); because we will extract 4 digit from list value
String rollno = rs.getString("rollno"); // in mouse click event.
String fname = rs.getString("fname");
String mname = rs.getString("mname"); if (Mno.length() < 4)
String address = rs.getString("address"); {
String city = rs.getString("city"); int x = Mno.length();
String religion = rs.getString("religion"); int nl = 4 - x;
String contact = rs.getString("contact"); while (nl > 0){
Mno = Mno + " ";
nl--;
}
} // Variables declaration - do not modify
dModel.addElement(Mno+ "- " + Mna); private javax.swing.JButton cmdExit;
} private javax.swing.JButton cmdExit1;
jList1.setModel(dModel); private javax.swing.JButton cmdUpdate;
} catch (Exception e) { private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
JOptionPane.showMessageDialog(this,e.getMessa private javax.swing.JLabel jLabel12;
ge()); private javax.swing.JLabel jLabel13;
e.printStackTrace(); private javax.swing.JLabel jLabel14;
} private javax.swing.JLabel jLabel15;
} private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private void private javax.swing.JLabel jLabel18;
cmdExit1ActionPerformed(java.awt.event.ActionE private javax.swing.JLabel jLabel19;
vent evt) { private javax.swing.JLabel jLabel2;
// TODO add your handling code here: private javax.swing.JLabel jLabel6;
private javax.swing.JList jList1;
new menu ().setVisible(true); private javax.swing.JScrollPane jScrollPane1;
dispose(); private javax.swing.JSeparator jSeparator2;
private javax.swing.JTextField jTextField1;
} private javax.swing.JTextField jTextField10;
private javax.swing.JTextField jTextField2;
/** private javax.swing.JTextField jTextField3;
* @param args the command line arguments private javax.swing.JTextField jTextField4;
*/ private javax.swing.JTextField jTextField5;
public static void main(String args[]) { private javax.swing.JTextField jTextField6;
java.awt.EventQueue.invokeLater(new private javax.swing.JTextField jTextField7;
Runnable() { private javax.swing.JTextField jTextField8;
public void run() { private javax.swing.JTextField jTextField9;
new delete().setVisible(true); private org.jdesktop.beansbinding.BindingGroup
} bindingGroup;
}); // End of variables declaration
} }
}
BIBILOGRAPHY
Book: INFORMATICS PRACTICES
Writtten by:
2. Oxford 12th IP