visit @ http://www.infotechcomputer.
in
“Jh x.ks'kk; ue%“
‘Java Project’
SPLASH SCREEN
Coding of start button
this.setVisible(false);
loginform k=new loginform();
k.setVisible(true);
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 1
visit @ http://www.infotechcomputer.in
LOGIN FORM
CODE OF LOGIN BUTTON
String un, pw;
un=jtfun.getText();
pw=jtfpw.getText();
if(un.equals("india") && pw.equals("123456"))
{
this.setVisible(false);
mainmenu k=new mainmenu();
k.setVisible(true);
}
else
{
JOptionPane.showMessageDialog(null,"Login Failed");
}
}
Code of cancel button
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 2
visit @ http://www.infotechcomputer.in
Student Admission
Coding of save button
Statement stmt; // statement class ka object java ke statement ko sql mein submit karne ke kaam aata hai
try // ye wala try / catch sql driver ko load karne mein aane wali errors ko display karega
{
Class.forName("java.sql.Driver");// java library ki sql package ki driver class ko load karo
}
catch(Exception e)
{
System.out.println(e);
}
try // ye baaki saari coding mein koi error hai to error display karega
{
String roll,name,cl,sec,add,city,phone;
roll=jtfroll.getText();
name=jtfname.getText();
cl=jtfclass.getText();
sec=jtfsec.getText();
add=jtfaddress.getText();
city=jtfcity.getText();
phone=jtfphone.getText();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/prateek","root",
"123456");
stmt = conn.createStatement(); // connection ko use kare hue ek statement create karo
String sql = "insert into student
values('"+roll+"','"+name+"','"+cl+"','"+sec+"','"+add+"','"+city+"','"+phone+"')";
stmt.executeUpdate(sql); // for insert, update and delete we use executeUpdate and for select query we
use executeQuery
JOptionPane.showMessageDialog(null,"Record Saved");
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 3
visit @ http://www.infotechcomputer.in
catch(SQLException e)
{
System.out.println(e);
Coding of return to main menu button
this.setVisible(false);
mainmenu k=new mainmenu();
k.setVisible(true);
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 4
visit @ http://www.infotechcomputer.in
Student Search Form
Coding of Search Button
Statement stmt;
ResultSet rs;
try
{
Class.forName("java.sql.Driver");
}
catch(Exception e)
{
System.out.println(e);
}
try
{
String roll,name,cl,sec,add,city,phone;
roll=jtfroll.getText();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/prateek","root",
"123456");
stmt = conn.createStatement();
String sql = "select * from student where roll='"+roll+"'";
rs=stmt.executeQuery(sql);
if(rs.next())
{
name=rs.getString("name");
cl=rs.getString("class");
sec=rs.getString("sec");
add=rs.getString("address");
city=rs.getString("city");
phone=rs.getString("phone");
jtfname.setText(""+name);
jtfclass.setText(""+cl);
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 5
visit @ http://www.infotechcomputer.in
jtfsec.setText(""+sec);
jtfaddress.setText(""+add);
jtfcity.setText(""+city);
jtfphone.setText(""+phone);
}
else
{
JOptionPane.showMessageDialog(null,"Sorry Record Not Found");
}
}
catch(SQLException e)
{
System.out.println(e);
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 6
visit @ http://www.infotechcomputer.in
Student Delete Form
Coding of Delete Button
Statement stmt;
try
{
Class.forName("java.sql.Driver");
}
catch(Exception e)
{
System.out.println(e);
}
try
{
String roll;
roll=jtfroll.getText();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/prateek","root",
"123456");
stmt = conn.createStatement();
String sql = "delete from student where roll='"+roll+"'";
stmt.executeUpdate(sql);
int k=JOptionPane.showConfirmDialog(null,"Are you sure you want to delete this record??");
if(k==0)
JOptionPane.showMessageDialog(null,"Record Deleted");
}
catch(SQLException e)
{
System.out.println(e);
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 7
visit @ http://www.infotechcomputer.in
Student Update Form
Coding of Update Button
Statement stmt;
try
{
Class.forName("java.sql.Driver");
}
catch(Exception e)
{
System.out.println(e);
}
try
{
String name,cl,sec,add,city,phone;
name=jtfname.getText();
cl=jtfclass.getText();
sec=jtfsec.getText();
add=jtfaddress.getText();
city=jtfcity.getText();
phone=jtfphone.getText();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/prateek","root",
"123456");
stmt = conn.createStatement();
String sql = "update student set name='"+name+"',
class='"+cl+"',sec='"+sec+"',address='"+add+"',city='"+city+"',phone='"+phone+"'";
int k=JOptionPane.showConfirmDialog(null,"Are you sure you want to update this record??");
if(k==0)
JOptionPane.showMessageDialog(null,"Record Updated Successfully");
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 8
visit @ http://www.infotechcomputer.in
}
catch(SQLException e)
{
System.out.println(e);
}
}
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 9
visit @ http://www.infotechcomputer.in
Result Add Form
Coding of Save Button
Statement stmt; // statement class ka object java ke statement ko sql mein submit karne ke kaam aata hai
try // ye wala try / catch sql driver ko load karne mein aane wali errors ko display karega
{
Class.forName("java.sql.Driver");// java library ki sql package ki driver class ko load karo
}
catch(Exception e)
{
System.out.println(e);
}
try // ye baaki saari coding mein koi error hai to error display karega
{
String roll,hindi,english,maths,social,science,total,percent,division;
roll=jtfroll1.getText();
hindi=jtfhindi.getText();
english=jtfenglish.getText();
maths=jtfmaths.getText();
social=jtfsocial.getText();
science=jtfscience.getText();
total=jtftotal.getText();
percent=jtfpercent.getText();
division=jtfdivision.getText();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/prateek","root",
"123456");
stmt = conn.createStatement(); // connection ko use kare hue ek statement create karo
String sql = "insert into result
values('"+roll+"','"+hindi+"','"+english+"','"+maths+"','"+social+"','"+science+"','"+total+"','"+percent+"','"+divi
sion+"')";
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 10
visit @ http://www.infotechcomputer.in
stmt.executeUpdate(sql); // for insert, update and delete we use executeUpdate and for select query we
use executeQuery
JOptionPane.showMessageDialog(null,"Record Saved");
}
catch(SQLException e)
{
System.out.println(e);
}
Coding of Calculate Button
int hindi,english,maths,social,science,total,percent;
String division;
jButton2.setEnabled(true);
hindi=Integer.parseInt(jtfhindi.getText());
english=Integer.parseInt(jtfenglish.getText());
maths=Integer.parseInt(jtfmaths.getText());
social=Integer.parseInt(jtfsocial.getText());
science=Integer.parseInt(jtfscience.getText());
total=hindi+english+maths+social+science;
percent=total/5;
division=percent>=60?"First":percent>=45?"Second":percent>=36?"Third":"Fail";
jtftotal.setText(""+total);
jtfpercent.setText(""+percent);
jtfdivision.setText(""+division);
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 11
visit @ http://www.infotechcomputer.in
Result Search Form
Code of Search Button
Statement stmt; // statement class ka object java ke statement ko sql mein submit karne ke kaam aata hai
ResultSet rs;
try // ye wala try / catch sql driver ko load karne mein aane wali errors ko display karega
{
Class.forName("java.sql.Driver");// java library ki sql package ki driver class ko load karo
}
catch(Exception e)
{
System.out.println(e);
}
try // ye baaki saari coding mein koi error hai to error display karega
{
String roll,hindi,english,maths,social,science,total,percent,division;
roll=jtfroll1.getText();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/prateek","root",
"123456");
stmt = conn.createStatement(); // connection ko use kare hue ek statement create karo
String sql = "select * from result where roll='"+roll+"'";
rs=stmt.executeQuery(sql); // for insert, update and delete we use executeUpdate and for select query we
use executeQuery
if(rs.next())
{
hindi=rs.getString("hindi");
english=rs.getString("english");
maths=rs.getString("maths");
social=rs.getString("social");
science=rs.getString("science");
total=rs.getString("total");
percent=rs.getString("percent");
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 12
visit @ http://www.infotechcomputer.in
division=rs.getString("division");
jtfhindi.setText(""+hindi);
jtfenglish.setText(""+english);
jtfmaths.setText(""+maths);
jtfsocial.setText(""+social);
jtfscience.setText(""+science);
jtftotal.setText(""+total);
jtfpercent.setText(""+percent);
jtfdivision.setText(""+division);
}
else
{
JOptionPane.showMessageDialog(null,"Record Not Found");
}
}
catch(SQLException e)
{
System.out.println(e);
}
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 13
visit @ http://www.infotechcomputer.in
Result Update Form
Code of Update Button
Statement stmt; // statement class ka object java ke statement ko sql mein submit karne ke kaam aata hai
try // ye wala try / catch sql driver ko load karne mein aane wali errors ko display karega
{
Class.forName("java.sql.Driver");// java library ki sql package ki driver class ko load karo
}
catch(Exception e)
{
System.out.println(e);
}
try // ye baaki saari coding mein koi error hai to error display karega
{
String roll,hindi,english,maths,social,science,total,percent,division;
roll=jtfroll1.getText();
hindi=jtfhindi.getText();
english=jtfenglish.getText();
maths=jtfmaths.getText();
social=jtfsocial.getText();
science=jtfscience.getText();
total=jtftotal.getText();
percent=jtfpercent.getText();
division=jtfdivision.getText();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/prateek","root",
"123456");
stmt = conn.createStatement(); // connection ko use kare hue ek statement create karo
String sql = "update result set
hindi='"+hindi+"',english='"+english+"',maths='"+maths+"',social='"+social+"',science='"+science+"',total='"+t
otal+"',percent='"+percent+"',division='"+division+"' where roll='"+roll+"'";
int k;
k=JOptionPane.showConfirmDialog(null,"R U Sure !!");
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 14
visit @ http://www.infotechcomputer.in
if(k==0)
stmt.executeUpdate(sql); // for insert, update and delete we use executeUpdate and for select query we
use executeQuery
JOptionPane.showMessageDialog(null,"Record Updated Successfully");
}
catch(SQLException e)
{
System.out.println(e);
}
Result Delete Form
Code of Delete Button
Statement stmt; // statement class ka object java ke statement ko sql mein submit karne ke kaam aata hai
try // ye wala try / catch sql driver ko load karne mein aane wali errors ko display karega
{
Class.forName("java.sql.Driver");// java library ki sql package ki driver class ko load karo
}
catch(Exception e)
{
System.out.println(e);
}
try // ye baaki saari coding mein koi error hai to error display karega
{
String roll,hindi,english,maths,social,science,total,percent,division;
roll=jtfroll1.getText();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/prateek","root",
"123456");
stmt = conn.createStatement(); // connection ko use kare hue ek statement create karo
String sql = "delete from result where roll='"+roll+"'";
int k;
k=JOptionPane.showConfirmDialog(null,"R U Sure !!");
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 15
visit @ http://www.infotechcomputer.in
if(k==0)
stmt.executeUpdate(sql); // for insert, update and delete we use executeUpdate and for select query we
use executeQuery
}
catch(SQLException e)
{
System.out.println(e);
}
}
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 16
visit @ http://www.infotechcomputer.in
Main Menu Form
Code of All Buttons
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
studentupdate k=new studentupdate();
k.setVisible(true);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
studentadmission k=new studentadmission();
k.setVisible(true);
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
studentsearch k=new studentsearch();
k.setVisible(true);
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
studentdelete k=new studentdelete();
k.setVisible(true);
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
resultdelete k=new resultdelete();
k.setVisible(true);
}
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 17
visit @ http://www.infotechcomputer.in
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
resultsearch k=new resultsearch();
k.setVisible(true);
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
resultadd k=new resultadd();
k.setVisible(true);
}
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
resultupdate k=new resultupdate();
k.setVisible(true);
}
INFOTECH Computer Education, Kishangarh (Raj) 9829171122 Page 18