import java.io.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class College extends JFrame implements ActionListener
{
JLabel lblid,lblname,lbladdr,lblyr;
JTextField txtid,txtname,txtaddr,txtyr;
JButton btninsert,btnclear,btnexit;
College()
{
setLayout(null);
lblid=new JLabel("College id");
lblname=new JLabel("College Name");
lbladdr=new JLabel("College Address");
lblyr=new JLabel("Year");
txtid=new JTextField();
txtname=new JTextField();
txtaddr=new JTextField();
txtyr=new JTextField();
btninsert=new JButton("Insert");
btnclear=new JButton("Clear");
btnexit=new JButton("Exit");
lblid.setBounds(20,30,100,20);
lblname.setBounds(20,70,150,30);
lbladdr.setBounds(20,110,150,30);
lblyr.setBounds(20,150,150,30);
txtid.setBounds(120,30,150,30);
txtname.setBounds(120,70,150,30);
14 txtaddr.setBounds(120,110,150,30);
txtyr.setBounds(120,150,150,30);
btninsert.setBounds(10,200,100,50);
btnclear.setBounds(120,200,100,50);
btnexit.setBounds(230,200,100,50);
btninsert.addActionListener(this);
btnclear.addActionListener(this);
btnexit.addActionListener(this);
add(lblid); add(txtid);
add(lblname); add(txtname);
add(lbladdr); add(txtaddr);
add(lblyr); add(txtyr);
add(btninsert);
add(btnclear);
add(btnexit);
setSize(500,400);
}
public void actionPerformed(ActionEvent a)
{
try {
if(a.getSource()==btninsert)
{
int id,yr;
String nm,add;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("Jdbc:Odbc:BCA");
PreparedStatement pst=con.prepareStatement("insert into College values(?,?,?,?)");
id=Integer.parseInt(txtid.getText());
nm=txtname.getText();
add=txtaddr.getText();
15 yr=Integer.parseInt(txtyr.getText());
pst.setInt(1,id);
pst.setString(2,nm);
pst.setString(3,add);
pst.setInt(4,yr);
pst.executeUpdate();
//int k= JOptionPane.showMessageDialog(null,"Record Inserted Successfully");
con.close();
/*if(k>0){System.out.println("Record Inserted..!!!");}else{System.out.println("Error..!!!");}*/ }
if(a.getSource()==btnclear)
{
txtid.setText("");
txtname.setText("");
txtaddr.setText("");
txtyr.setText("");
}
if(a.getSource()==btnexit)
{
System.exit(0);
}
}
catch(Exception e)
{
System.out.println("Error is :"+e);
}
}
public static void main(String args[])
16 {
new College().show();
}
}
Search
Blog Archive
-
▼
2017
(64)
-
▼
March
(44)
- Write a Socket program in java in which client acc...
- Write a Socket program in java for chatting applic...
- Create a JSP page to accept a number from an user ...
- Write a JSP script to check whether given mail ID ...
- Write a JSP script to accept the details of Studen...
- Write a JSP script to accept username, store it in...
- Write a SERVLET program in java to accept details ...
- Write a SERVLET program that provides information ...
- Write a SERVLET program which counts how many time...
- Write a Multithreading program in java to convert ...
- Write a java program which will display name and p...
- Write a Multithreading program in java to display ...
- Write a java program using multithreading to execu...
- Write a Multithreading program in java using Runna...
- Write a java program to simulate traffic signal us...
- Write a menu driven java program for the following
- Write a java program to accept the details of coll...
- Write a JDBC application using swing for the follo...
- Write a JDBC program in java to display details of...
- Write a JDBC program to delete the records of empl...
- Write a JDBC program to accept the details of cust...
- Don't Quit Inspiring Poem..
- Something Very useful information
- C++ Program.Write a program to display area of squ...
- C++ Program. Write a program to display area of tr...
- C++ Program .Write a program convert fharenhite to...
- C++ Program .Write a program to display simple int...
- C++ Program .Write a program to input an integer n...
- C++ Program .Write a program to print factorial us...
- C++ Program .Write a program to print following pa...
- C++ Program .Write a program to nested structure
- C++ Program .Write a program to open file for reading
- C++ Program .Write a program to append the content...
- C++ Program .Write a program to create new file an...
- C++ Program .Write a program to accept n book deta...
- C++ Program Write a ‘C’ Program to count the numbe...
- C++Write menu driven program to convert decimal nu...
- C++ program to check whether given number is Palin...
- Write a C program to accept three integers as com...
- Write a program, which accepts a number n and disp...
- Write a menu driven program in C to create a stru...
- Write a C program to accept n different numbers a...
- Write a C program to calculate sum of digits till...
- Write a C program to swap two numbers using bitwis...
-
▼
March
(44)
Popular Posts
-
Emp.html <html> <body> <form method="POST" action="Lic.php"> Enter EMP No : <input ty...
-
class SortCity { public static void main(String arg[]) { String name[]=new Stri...
-
#include<stdio.h> #include<conio.h> main() { int num,rem=0,digit; clrscr(); printf("Enter number="...
-
Program to accept Book details of ‘n’ books as book_title, author, publisher and cost. Assign the accession number to each book in incre...
-
<?php interface Cyl { function area(); functi...
Categories
- BCA Sem VI Advance Java Slips Solution
- Ebooks
- FYBCA ( Sem–II) Assignment No.2 Decision making and looping.(solved assignment)
- FYBCA ( Sem–II) Assignment No.3 using function.(solved assignment)
- FYBCA ( Sem–II) Assignment No.4 Array program.(solved assignment)
- INFORMATION ABOUT TALLY.ERP 9
- RDBMS Assignment
- RDBMS ASSIGNMENT
- TYBCA (Sem IV) Java Programs
- TYBCA (Sem VI) Adv Java Programs
- TYBCA PHP Assignment