Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC Jdbc Program for building Student Information Database

Have Programming Question? Ask it here!
 
 
 


Avishek Bhattacharyya
Jdbc Program for building Student Information Database
1 Answer(s)      4 years and a month 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.


Advertisement
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 Tutorials/Questions & Answers:
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
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
Advertisements
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
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
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
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
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
get information from database
get information from database  get information from database   Please visit the following links: http://www.roseindia.net/sql/mysql-table/mysql-php-select.shtml http://www.roseindia.net/sql/mysql-example/select
Java GUI to build a Student Registration Program
Java GUI to build a Student Registration Program   Write a program... by creating a driver program to load the student data base and the course data... if the student is successfully registered for the course. Graduate students can
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
jdbc program
jdbc program   Write a program to update the salaryRs.6000/- for an employee name like ‚??P. Ramu‚?? using prepared statement
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
Write a JSP program to display the grade of a student by accepting the marks of five subjects.
Write a JSP program to display the grade of a student by accepting the marks of five subjects.  Write a JSP program to display the grade of a student by accepting the marks of five subjects
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
database - JDBC
database  hai friend, yes i want to use java database connection in eclipse IDE. Thanks in advance
Displaying Database information on the browser.
PHP DATABASE Information Part-5(b): Displaying Data (with the help of PHPMyAdmin) Up to now, we learned how to create database and insert information in the database. In this tutorial, I will show you how to insert the information
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
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
check box realtive information in page store in database
check box realtive information in page store in database  check box relative information in page store in database  hiiiiiiiii, Que I create a checkbox in html and when i click on my check box realtive information
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
get information about foreign keys - JDBC
get information about foreign keys  How to get the information about foreign keys in Java
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 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'
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
Database Connection - JDBC
Database Connection  In java How will be connect Database through JDBC?  Hi Friend, Please visit the following link: http://www.roseindia.net/jdbc/jdbc-mysql/MysqlConnect.shtml Thanks
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
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
database connectivity - JDBC
database connectivity  can u ppl pls provide me with database... a user DSN 4. Select Microsoft Access Driver(*.mdb) 5. Select database name.... For programs,visit the following links: http://www.roseindia.net/jdbc/Jdbc-odbc
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
execution of a jdbc program
execution of a jdbc program  how to execute a servlet program that..uses a jdbc driver (i.e. using mysql-connector -java )to connect to mysql in windows *PLS provid the execution steps in detail THANK YOU
image store in database - JDBC
; Inserting Image in Database Table http://www.roseindia.net/jdbc/jdbc-mysql/insert... into the database what is the process to do that? Please explain... to store image into database. Check at http://www.roseindia.net/servlets/insert
image retrive into DataBase - JDBC
the image into DataBase. Thanks & Regards, VijayaBabu.M  Hi, Retrieving image from database is easy task. JDBC provides all the necessary API and function to retrieve the image from database. You retrieve image from database
database retrieving - JDBC
database retrieving  how to retrieve resultset from table which we have created in 'SQL SERVER MANAGEMENT STUDIO' using java program
Write a program using JSP that enables any student to change his/her address.
Write a program using JSP that enables any student to change his/her address.  Write a program using JSP that enables any student to change his/her address
Accessing database with JDBC via Java
Accessing database with JDBC via Java  How to access a database with JDBC via Java application?   Accessing database with JDBC through Java JDBC Example to access Database import java.sql.*; public class JdbcConnect
java database connection - JDBC
java database connection  sir i want to join my project with MS access database. i am making my project in netbeans.please tell me the coding to do... the data into the MS Access database and retrieve the data from the database table
C Program with Database Connectivity
C Program with Database Connectivity  How To Connect MySQL Database in C Program with Graphics
java database error - JDBC
java database error  hi all i am writing one swing application where i want to insert data into database(MS-Access) but dont know how to do... the following code to insert the data into MS-Access database: import java.sql.
Oracle Database error - JDBC
Oracle Database error   String query11 = "SELECT product_code, product_quantity, price FROM o"+orderid; ResultSet rs11... = DriverManager.getConnection("jdbc:mysql://localhost:3306/register", "root", "root"); Statement
Connecting JTable to database - JDBC
to store this JTable content in my database table.. This is a very important...("jdbc:odbc:access"); for(int i=0;i  Hi Friend, Make one change
Java Program - JDBC
Java Program  A java Program that display data from a Table in MSAccess in JTable using JFrame  Hi Friend, Try the following code...("jdbc:odbc:access"); String sql = "Select * from data"; Statement stmt
database connectivity in java - JDBC
database connectivity in java  import java.io.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.sql.*; class... con1; con1=DriverManager.getConnection("jdbc:odbc:Mycon
cannot connect to database - JDBC
cannot connect to database  Iam using eclipse in my system ,when connecting the database mysql version 5.0 to the eclipse iam getting an error as ""Creating connection to mysql has encountered a problem.Could not connect to mysql
program to create student report using java applet,read the input using text boxesand generate the grades..?
program to create student report using java applet,read the input using text boxesand generate the grades..?   sir plz give me java applet codes for above question
Help on JDBC and my SQL 5 database - JDBC
Help on JDBC and my SQL 5 database  Dear Sir, I had create a statement for the JDBC as shown below: try... the connection c = DriverManager.getConnection ("jdbc:mysql
JDBC Oracle program
JDBC Oracle program  Here is my code: import java.sql.*; public class Tyagi { public static void main (String args[])throws SQLException... = DriverManager.getConnection("jdbc:oracle:thin:@localhost:8080:oracle", "System", "System
Java Program - JDBC
Java Program  A java program that display in in a table in JTable
Advertisements
 

 

 

DMCA.com