Home Answers Viewqa JDBC Jdbc Program for building Student Information Database

 
 


Avishek Bhattacharyya
Jdbc Program for building Student Information Database
1 Answer(s)      2 years and 9 months ago
Posted in : JDBC

import java.awt.*;
 import java.awt.event.*;
 import java.sql.*;
  public class College implements ActionListener  {   Panel p;  Frame f;
  Button b1,b2,b3,b4,b5,b6,b7;  TextField tf1,tf2,tf3,tf4,tf5,tf6,tf7;
  Label l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15;  GridLayout gl;
  Connection con;
  Statement st;
  String s1,s2,s3,s4,s5,s6,s7,sr1,sr2;
  TextArea ta1;
  College()  {   f=new Frame();
   p=new Panel();
   p.setBackground(Color.cyan);
   gl=new GridLayout(31,8,3,3);
   p.setLayout(gl);
   b1=new Button("Insert");
   b1.addActionListener(this);
      b2=new Button("Select");
   b2.addActionListener(this);
      b3=new Button("Select");
   b3.addActionListener(this);
      b4=new Button("Results");
   b4.addActionListener(this);
   b5=new Button("Select");
   b5.addActionListener(this);
   b6=new Button("Exam");
   b6.addActionListener(this);
   b7=new Button("Submit");
   b7.addActionListener(this);
   tf1=new TextField(50);
   tf1.setBackground(Color.yellow);
   tf2=new TextField(10);
   tf2.setBackground(Color.yellow);
   tf3=new TextField(50);
   tf3.setBackground(Color.yellow);
   tf4=new TextField(20);
   tf4.setBackground(Color.yellow);
   tf5=new TextField(6);
   tf5.setBackground(Color.yellow);
   tf6=new TextField(10);
   tf6.setBackground(Color.yellow);
   tf7=new TextField(10);
   tf7.setBackground(Color.yellow);
   tf8=new TextField(10);
   tf8.setBackground(Color.yellow);
   ta1=new TextArea(10,2);
   l1=new Label("Enter student info");
   l2=new Label("Update student info");
   l3=new Label("View student info");
   l4=new Label("View results");
   l5=new Label("Delete student info");
   l6=new Label("View exam details");
   l7=new Label("Name");
   l8=new Label("Roll");
   l9=new Label("Address");
   l10=new Label("Phone");
   l11=new Label("E-Mail");
   l12=new Label("Gender");
   l13=new Label("Date of Birth");
   l14=new Label("Result");
   l15=new Label("Exam Details");
   p.add(l1);
p.add(b1);
p.add(l2);
p.add(b2);
p.add(l3);
p.add(b3);
p.add(l4);
p.add(b4);
p.add(l5);
p.add(b5);
p.add(l6);
p.add(b6);  
p.add(l7);
p.add(tf1);
p.add(l8);
p.add(tf2);
p.add(l9);
p.add(tf3);
p.add(l10);
p.add(tf4);
p.add(l11);
p.add(tf5);
p.add(l12);
p.add(tf6);
p.add(l13);
p.add(tf7);
p.add(b7);
p.add(l14);
p.add(tf8);
p.add(l15);
p.add(ta1); 
f.add(p);
   f.setSize(100,200);
   f.setVisible(true);
   }  public void actionPerformed(ActionEvent e)  {   if(e.getSource()==b1)  { try {    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");    con=DriverManager.getConnection("jdbc:odbc:Avishek");   
s1=tf1.getText();  
s2=tf2.getText();   
s3=tf3.getText();  
s4=tf4.getText(); 
s5=tf5.getText();   
s6=tf6.getText();   
s7=tf7.getText();   
st=createStatement.executeQuery("insert into Table1 values(?,?,?,?,?,?,?)");   
    st.setString(1,s1);   
st.setString(2,s2);   
st.setString(3,s3); 
st.setString(4,s4);   
st.setString(5,s5);       
st.setString(6,s6);  
st.setString(7,s7);   
st.executeUpdate();  
st.execute();       
st.close();  
}  catch(Exception i)  
{  System.out.println("Error");  
} }      if(e.getSource()==b2)   
{  try  {    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");    con=DriverManager.getConnection("jdbc:odbc:Avishek");       s1=tf1.getText();    s2=tf2.getText();    
st=createStatement.executeQuery("update Table1 set Name=?"+"where Roll=?");
    st.setString(1,s1); 
st.setString(2,s2);   
    st.executeUpdate();   
st.execute();      st.close();  
}   catch(Exception i)   {  
System.out.println("Error");   }  } 
    if(e.getSource()==b3)    {    try     {      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");      con=DriverManager.getConnection("jdbc:odbc:Avishek");    
ResultSet rs=con.createStatement("Select * from Table1"); 
 while(rs.next()) { 
  String s1=rs.Name; 
String s2=rs.Roll; 
String s3=rs.Address;  
String s4=rs.Phone;  
String s5=rs.E-Mail;  
String s6=rs.Gender; 
String s7=rs.Date Of Birth; 
tf1.setText(s1); 
tf2.setText(s2);  
tf3.setText(s3); 
tf4.setText(s4);  
tf5.setText(s5); 
tf6.setText(s6); 
tf7.setText(s7);  
  }                 
rs.close();      } }    catch(Exception i)   {    System.out.println("Error");  
}  }  if(e.getSource()==b4)   
{    try     {   
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");      con=DriverManager.getConnection("jdbc:odbc:Avishek");   
s2=tf2.getText();          
ResultSet rs1=con.createStatement("select from Result where SRoll=?");      while(rs.next())    
{      if(s2.equals(Roll))         
{       String sr1=rs.SRoll;   
String sr2=rs.SResult;     
tf2.setText(sr1);   
tf8.setText(sr2);    
      }    }  
    rs.close();    
 }    catch(Exception i)  
{    System.out.println("Error");  
}  }  if(e.getSource()==b5)   
{    try  
{      s2=tf2.getText();    
st=createStatement.executeQuery("delete from Somu where Roll=?");      st.setString(2,Roll);   
st.executeUpdate();     
st.execute();          
st.close();      } }    catch(Exception i)   
{    System.out.println("Error");   }  }  
if(e.getSource()==b6)  
{     String exam="\nB-Tech 1st sem starts 12.2.2010.\n"+                 "\nB-Com 1st sem starts 10.2.2010.\n"+     
"\nMBA 1st sem starts 15.2.2010.\n";  
ta1.setText(exam);       
      }      }  
public static void main(String args[])  
{   College c=new College();   } }  

In the above program It'd be helpful if the errors could be corrected.Also I'd like to see the pannel change when the buttons are clicked.For example,if Insert is clicked,the panel containing student name,address,ph.,e-mail,gender,date of birth should appear.

View Answers

October 17, 2012 at 7:16 PM


import java.awt.*;
import java.awt.event.*;
import java.sql.*;

public class College implements ActionListener
{

Panel p;
Frame f;
Button b1,b2,b3,b4,b5,b6,b7;
TextField tf1,tf2,tf3,tf4,tf5,tf6,tf7;
Label l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15;
GridLayout gl;
Connection con;
Statement st;
String s1,s2,s3,s4,s5,s6,s7,sr1,sr2;
TextArea ta1;
College()
{
f=new Frame();
p=new Panel();
p.setBackground(Color.cyan);
gl=new GridLayout(31,8,3,3);
p.setLayout(gl);
b1=new Button("Insert");
b1.addActionListener(this);

b2=new Button("Select");
b2.addActionListener(this);

b3=new Button("Select");
b3.addActionListener(this);

b4=new Button("Results");
b4.addActionListener(this);
b5=new Button("Select");
b5.addActionListener(this);
b6=new Button("Exam");
b6.addActionListener(this);
b7=new Button("Submit");
b7.addActionListener(this);
tf1=new TextField(50);
tf1.setBackground(Color.yellow);
tf2=new TextField(10);
tf2.setBackground(Color.yellow);
tf3=new TextField(50);
tf3.setBackground(Color.yellow);
tf4=new TextField(20);
tf4.setBackground(Color.yellow);
tf5=new TextField(6);
tf5.setBackground(Color.yellow);
tf6=new TextField(10);
tf6.setBackground(Color.yellow);
tf7=new TextField(10);
tf7.setBackground(Color.yellow);
tf8=new TextField(10);
tf8.setBackground(Color.yellow);
ta1=new TextArea(10,2);
l1=new Label("Enter student info");
l2=new Label("Update student info");
l3=new Label("View student info");
l4=new Label("View results");
l5=new Label("Delete student info");
l6=new Label("View exam details");
l7=new Label("Name");
l8=new Label("Roll");
l9=new Label("Address");
l10=new Label("Phone");
l11=new Label("E-Mail");
l12=new Label("Gender");
l13=new Label("Date of Birth");
l14=new Label("Result");
l15=new Label("Exam Details");
p.add(l1);p.add(b1);p.add(l2);p.add(b2);p.add(l3);p.add(b3);p.add(l4);p.add(b4);p.add(l5);p.add(b5);p.add(l6);p.add(b6);
p.add(l7);p.add(tf1);p.add(l8);p.add(tf2);p.add(l9);p.add(tf3);p.add(l10);p.add(tf4);p.add(l11);p.add(tf5);p.add(l12);p.add(tf6);p.add(l13);p.add(tf7);p.add(b7);p.add(l14);p.add(tf8);p.add(l15);p.add(ta1);
f.add(p);
f.setSize(100,200);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{

if(e.getSource()==b1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Avishek");
s1=tf1.getText();
s2=tf2.getText();
s3=tf3.getText();
s4=tf4.getText();
s5=tf5.getText();
s6=tf6.getText();
s7=tf7.getText();
st=createStatement.executeQuery("insert into Table1 values(?,?,?,?,?,?,?)");

st.setString(1,s1);
st.setString(2,s2);
st.setString(3,s3);
st.setString(4,s4);
st.setString(5,s5);
st.setString(6,s6);
st.setString(7,s7);

st.executeUpdate();
st.execute();



st.close();
}
catch(Exception i)
{
System.out.println("Error");
}
}

if(e.getSource()==b2)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Avishek");
s1=tf1.getText();
s2=tf2.getText();

st=createStatement.executeQuery("update Table1 set Name=?"+"where Roll=?");
st.setString(1,s1);
st.setString(2,s2);

st.executeUpdate();
st.execute();

st.close();
}
catch(Exception i)
{
System.out.println("Error");
}
}

if(e.getSource()==b3)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Avishek");
ResultSet rs=con.createStatement("Select * from Table1");

while(rs.next())
{

String s1=rs.Name;
String s2=rs.Roll;
String s3=rs.Address;
String s4=rs.Phone;
String s5=rs.E-Mail;
String s6=rs.Gender;
String s7=rs.Date Of Birth;
tf1.setText(s1);
tf2.setText(s2);
tf3.setText(s3);
tf4.setText(s4);
tf5.setText(s5);
tf6.setText(s6);
tf7.setText(s7);


}


rs.close();
}
}
catch(Exception i)
{
System.out.println("Error");
}
}
if(e.getSource()==b4)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Avishek");
s2=tf2.getText();

ResultSet rs1=con.createStatement("select from Result where SRoll=?");
while(rs.next())
{
if(s2.equals(Roll))
{
String sr1=rs.SRoll;
String sr2=rs.SResult;
tf2.setText(sr1);
tf8.setText(sr2);

}
}
rs.close();

}
catch(Exception i)
{
System.out.println("Error");
}
}
if(e.getSource()==b5)
{
try
{
s2=tf2.getText();
st=createStatement.executeQuery("delete from Somu where Roll=?");
st.setString(2,Roll);
st.executeUpdate();
st.execute();

st.close();
}
}
catch(Exception i)
{
System.out.println("Error");
}
}
if(e.getSource()==b6)
{
String exam="\nB-Tech 1st sem starts 12.2.2010.\n"+
"\nB-Com 1st sem starts 10.2.2010.\n"+
"\nMBA 1st sem starts 15.2.2010.\n";
ta1.setText(exam);

}


}
public static void main(String args[])
{
College c=new College();
}
}









Related Pages:
Jdbc Program for building Student Information Database - JDBC
Jdbc Program for building Student Information Database  import... TextArea(10,2); l1=new Label("Enter student info"); l2=new Label("Update student info"); l3=new Label("View
PLEASE Help me write a Java program which will store, manipulate, and print student registration information.
student registration information.  HERES TEH QUESTION - I AM MISSING SOME... will store, manipulate, and print student registration information. As part... and manipulates the student information (student record). Because the list of students
Write a program to get student details and store in a database
Write a program to get student details and store in a database  Write a program to get student details and store in a database
student
student  how do i create a program that writes out the message :Welcome to Kaplan University!"   Hi Friend, Try the following code: class Message { public static void main(String[] args
student
how many times has the user guessed a number. The program should display user... a number again until user has entered the correct number. The program should allow
html code for student information?
html code for student information?  html code for student information
student information system
student information system  can you show me example of "student information system" pseudo code and flow chart with "student name, student id, student residential hall, student course, student phone numbers
regarding connectivity program only - JDBC
for more information. http://www.roseindia.net/jdbc...regarding connectivity program only  can u give me code regarding .. that i had created student data base with his name and subject marks resp ... i
JDBC Database URLs
JDBC Database URLs In this Section, We will discuss about following topics : JDBC Database URL specify a JDBC driver name Connection to a database table JDBC Database URL JDBC Uniform resource locater or 'JDBC URL'
Student database
Student database  Create a class Student with Name, Gender, and Date of Birth and Input Student and print as ?Dear Mr/Mrs Name, your Age is 99 Years?. Mr/Mrs - only one should be displayed based on their age and Gender
student database
student database  student records such as fees-school fees, dob,age,if any due.the record stored should be like this record,name,age,dob,fee list or any dues of the student record1 isha 15 20jan record2 spandana 14 4feb record3
jdbc
how i can access Microsoft Access database by java program  how i can access Microsoft Access database by java program ? if any package or jar file...("jdbc:odbc:student"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver
college student admission
college student admission  Front End -JAVA Back End - MS Access Hello Sir, I want College Student Admission Project in Java with Source code, that includes Following Forms 1) Student Admission based on Enterance Exam Marks
Student Admission Form in Java - Java Beginners
Student Admission Form in Java  I want to store following Information into MS Access 2007 with JDBC. 1)Student PRN Number 2)Student Name 3)Date... = "jdbc:odbc:student"; private Connection getAccessConnection
add record to database - JDBC
add record to database  How to create program in java that can save record in database ?  Hi friend, import java.io.*; import java.sql....(); String url = "jdbc:mysql://localhost:3306/"; String db = "register
jdbc - JDBC
jdbc   kindly give the example program for connecting oracle dase...*; import oracle.jdbc.driver.*; import oracle.sql.*; 2) Load and Register the JDBC..."); 3) Connect to database:*********** a) If you are using oracle oci driver
jdbc - JDBC
information. http://www.roseindia.net/jdbc/ Thanks... name in Database!"); System.out.println("Welcome"); try...("jdbc:mysql://localhost:3306/ram","root","root"); System.out.println("Connect
Jdbc and Socket Program - JDBC
Jdbc and Socket Program  Sir, I would like to get a program i... in a database.Now we create another program 4 client-server such that the sever's database is updated everytime we enter username and password in client program
Student Information System in Java - Java Beginners
Student Information System in Java  Hello Sir, I want Mini Java Project for Student Admission System.  Hi Friend, Can you provide us details regarding your project like student admission form, faculty information
creating an applet for student management system
creating an applet for student management system  Write an applet/awt application which displays the interface for the program described below. When... in the appropriate layout, and responds to the user's actions. The program simulates
JDBC - Java Database Connectivity Tutorial
connection between program and database by using connection interface and JDBC... JDBC - Java Database Connectivity Tutorials  ... stored into the database. Here is the complete tutorial on JDBC technology
sorting student record - Java Beginners
sorting student record  Program in java for inserting, recording, deleting, editing and searching student details   can u explain about recording ? u want to store value in database or in file or opertinng run time
student info
student info  code of insert,delete,update,view,search of student information using jsp and servelts   Hi Friend, Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http
Student average
Student average  you are an academic scholar.one requirement to maintain this status is to maintain an average not below 1.8. write a java program that reads student's number of subject taken, the final grade of each subject
jdbc
jdbc define batch updates  define batch updates?exp   JDBC... are executed simultaneously to a database as a single unit. The batch is sent to the database in a single request using connection object. The advantage of batch
Building Search Engine Applications Using Servlets !
Building Search Engine Applications Using Servlets Introduction This tutorial takes you through the process of building search engine... some prior knowledge of Java Servlets. JDBC programming
Student Marks
Student Marks  Hi everyone I have to do this java assignment, and having trouble with it please help me. Write a program to compute the computer programming grades of 8 IT students. Randomly create student numbers for each
College Student Admission System Project in Java
OF ASMISSION 2) Student Information 3) Faculty Information 4) Courses -that can...College Student Admission System Project in Java   Front End -JAVA Back End - MS Access Hello Sir, I want College Student Admission Project in Java
jdbc
how to connect JSP page to database - JDBC  how to connect JSP page to database ?give program
JDBC
between java and mysql using JDBC and saves the data into the database. import... information, visit the following link: JDBC Tutorials...JDBC save a data in the database  I need a code to save a data
JDBC
the connection between java and mysql using JDBC and saves the data into the database... information, visit the following link: JDBC Tutorials...JDBC code to save a data in the database  I need a code to save
jdbc
information, visit the following link: JDBC Tutorials...jdbc  how to display database contents?   import java.sql....(); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost
jdbc-oracle - JDBC
jdbc-oracle  Hi! sub: image insertion in oracle: I inserted the image in oracle database using java through jdbc-odbc bridge driver... though my java program compiles and runs without any error. Pl. answer
regarding jdbc - JDBC
Parameter "username" "password" of the database. For more information...regarding jdbc  i am using this program /* import java.sql....").newInstance(); con = DriverManager.getConnection("jdbc:mysql:///test
jdbc
jdbc  how to update int values of ms-access in jdbc program?   In MS Access database, use Number data type for int values. import... =DriverManager.getConnection("jdbc:odbc:access","",""); Statement st=null; st
database entry using jdbc
database entry using jdbc  Give me a program to enter records in table using jdbc in java.   Hi Friend, Please visit the following link: Insert data into database Thanks
JDBC
JDBC  write a JDBC program to display the result of any query on a student table in a JTable component.   import java.awt....").newInstance(); Connection con = DriverManager.getConnection("jdbc:mysql://localhost
jdbc
jdbc  write a java program to accept the details of employee(eno,ename,sal)from the user and insert into the database(use awt
What is JDBC?
  Hi, JDBC stands for Java Database Connectivity. It is a set of API for connecting the database from Java program. JDBC API provides the API for: Connecting to database Getting the database information Performing add, update
database connectivity - JDBC
(); } } } For more information on JDBC in java visit to : http://www.roseindia.net/jdbc...database connectivity  example java code for connecting Mysql database using java  Hi friend, Code for connecting Mysql database using
image displaying from database with some other information
image displaying from database with some other information  hi, in the following section of code when i am not displaying the image it is working...=DriverManager.getConnection("jdbc:mysql://localhost:3306/online","root","root
java program - JDBC
of tables as fields, in this case i have three tables, i need a java program... out. i have used mysql for connecting to the database.  Hi friend, Please give details to solve the problem. For read JDBC connection
JDBC, Java Database Connectivity
with the Database from Java program. The JDBC is a set a API which works... tutorials. Java Database Connectivity or JDBC for short is Java bases API... to database and then get the database information. After making a connection
Database drivers - JDBC
Database drivers  Please give me types of drivers and explain them.   Hi friend, There are four types of JDBC drivers known as: * JDBC-ODBC bridge plus ODBC driver, also called Type 1
database retrieving - JDBC
database retrieving  how to retrieve resultset from table which we have created in 'SQL SERVER MANAGEMENT STUDIO' using java program
showing the information of database in textbox
showing the information of database in textbox  how to make a information of a database make appear to the user in the textbox
jdbc connection to java program code - JDBC
jdbc connection to java program code  i want a simple java program that which communicates with oracle database like creating table,insert values and update records in database and show in program output? please take a simple
Java code - JDBC
Java code  Write a Java Program Using JDBC that Runs On LAN and Enter the Student Infomation and Store them in the Database Crated on Server Computer
JDBC - JDBC
JDBC  i am goint to work on JDBC and i knew oracle but very poor in java is it possoble to me to do JDBC is it so please give me SOME SAMPLE ILLUSTRATIONS to understand the way to do work in JDBC with syntaxes  Hi
JDBC - JDBC
JDBC  how can i do jdbc through oracle.. pls if u can send me d.... thanking u santosh.  Hi Friend, Use JDBC with Oracle Follow...) Load and Register the JDBC driver:*********** DriverManager.registerDriver(new

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.