Professional Documents
Culture Documents
Year : II Semester: IV
Branch : CSE
Reg. No : 312419104020
BONAFIDE CERTIFICATE
LAB HOD
LAB IN-CHARGE
DATE:
DATE:
LAB HOD
LAB IN – CHARGE
DATE :
DATE :
DATE: DATE :
INTERNAL EXAMINER
DATE :
2
INDEX
Name of the Lab: CS8481/DBMS Name of the Staff:
Date of
S.No. Name of the Experiment Page No.
Exp.
Data Definition Commands, Data Manipulation
1. 25.02.21 Commands for inserting, deleting, updating and 4 To 11
retrieving Tables and Transaction Control statements
Database Querying – Simple queries, Nested queries,
2. 04.03.21 12 To 21
Sub queries and Joins
6. 05.04.21 Triggers 32 To 33
3
Exp.No:1DATA DEFINITION COMMANDS, DATA MANIPULATION
COMMANDS FOR INSERTING, DELETING, UPDATING AND RETRIEVING
TABLES AND TRANSACTION CONTROL STATEMENTS
AIM:
To design and implement a database for manipulating & storing data items in Oracle by using SQL
commands.
CREATE: (Syntax)
Database:
Create database <database name>;
Use <database name>;
Table:
Create table <table name> (column_name1 datatype1 constraints, column_name2 datatype2
constraint....column_nameNdatatypeN constraints);
4
3) Savepoint
COMMIT:
Commit;
ROLLBACK:
Rollback to <savepoint>;
SAVEPOINT:
Savepoint<savepoint name>;
PROBLEM STATEMENT:
Table Name:Branch_m
> create table branch_m(branch_name varchar(20) primary key,branch_city varchar(20),asset int);
5
sql> desc loan_m;
2.Alter the table branch_m by increasing the field width of branch city to 25.
SQL>desc branch_m;
sql> alter table branch_m modify branch_cityvarchar(25);
6
sql> alter table loan_madd primary key(loan_no);
7
8)a) Drop customer_ma
8
1_93 Mianus 500
l_102 Mianus Null
9
10. Find the names of all branches in loan relation.
sql> select branch_name from loan_m;
BRANCH_NAME
Perryridge
Downtown
Brighton
Redwood
Mianus
Roundhill
Mianus
Mianus
11. Find the names of all branches in loan relation by eliminating duplicate values.
.
sql> select distinct branch_name from loan_m;
BRANCH_NAME
Roundhill
Downtown
Perryridge
Redwood
Mianus
sql>commit;
sql>savepoint s1;
10
savepoint created.
Result:
Thus the SQL commands have been executed and the output was verified successfully.
11
Exp. No:2 DATABASE QUERYING – SIMPLE QUERIES, NESTEDQUERIES,
SUB QUERIES AND JOINS
DATE:04.03.21
AIM:
To implement and execute a query for manipulating & storing dataitems in sql
database using Structured Query Language commands
(INNER) JOIN
12
Output:
SELECT
Student.NAME,StudentCourse.COURSE_I
D FROM Student
LEFT JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
Output:
SELECT
Student.NAME,StudentCourse.COURSE_I
D FROM Student
RIGHT JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
13
Output:
SELECT
Student.NAME,StudentCourse.COURSE_I
D FROM Student
FULL JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
14
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
Output:
SIMPLE QUERIES
1. Display the loan relation with attributes amount multiplied by 100.
sql> select amount*100 from loan_m;
+ +
| amount*100|
+ +
| 90000 |
| 150000 |
| 150000 |
| 130000 |
| 100000 |
| 200000 |
| 50000 |
7 rows in set
2. Find all numbers for loan made at perryridge branch with loan
amount greaterthan 1400.
sql> select loan_no from loan_m where branch_name='perryridge' and
amount>1400;
+ +
| loan_no|
+ +
15
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
|l_15 |
+ +
1 row in set
3. Find all loan numbers for loan’s with loan amount between 900 and1500.
sql> select loan_no from loan_m where amount between 900 and 1500;
+ +
| loan_no|
+ +
|l_11 |
|l_14 |
|l_15 |
|l_16 |
|l_17 |
+ +
5 rows in set
16
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
7 rows in set
17
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
+ +
| 6|
+ +
1 row in set
8. Find all the loan number that appears in the loan relation
with NULL values for amount.
sql> select loan_no from loan_m where amount is null;
+ +
| loan_no|
+ +
|l_102 |
+ +
1 row in set
1. Findallthenameofallbranchesthathaveassetsgreaterthanatleastone
bank located in Stanford. (Nestedqueries)
sql> Select branch_name from branch_ma where assets >ANY (select
assetsfrom branch_ma where branch_city='stanford'); BRANCH_NAME
18
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
R
e
d
w
o
o
d
M
i
a
n
u
s
R
o
u
n
d
h
i
l
l
2. Displaytheentirecustomernameinalphabeticalorderthathav
eloanin Perryridge.(Nested queries).
CUSTOMER_NAME
Johnson
19
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
c
_
0
3
c
_
0
5
4. Findallcustomerswhohaveloanatbankbutwhodon’thaveaccountatsame
branch.(Nested queries).
CUSTOMER_ID
c
_
0
1
c
_
0
1
5. Findthenameofallbranchesthathaveassetsgreaterthanthoseatle
astone branch located in Harrison.(Nestedqueries).
20
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
where branch_city='Harrison');
BRANCH_NAME
Mianus
Result:
Thus, The SQL commands have been executed and the output was verified
successfully.
21
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
AIM:
To implement and execute view,sequence,indexes,savepoint in using SQL commands.
VIEWS:
Create view <viewname> as any select query; (Ex: select * from <tablename> where
<condition>)
SEQUENCE:
Create table <tablename> (column1 datatype1primary key auto_increment,column2 datatype
2……columnNdatatypeN)
SYNONYM:
Create synonym<synonym name> for <table name>;
VIEWS:
1) Create a view using aggregate functions to calculate the age of the Person
sql> create table person_m(name varchar(20) primary key,dobdate,person_city varchar(20));
22
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
| jorden | 45.0842 |
| maheshboobathy | 41.1006 |
| sachin | 42.2615 |
| viswanathanand | 45.4237 |
SEQUENCE:
2) Create a sequence and design the department table in the given attribute.
sql>descdepartment_m;
SYNONYM(UsingOracle)
23
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
Product 1 99 1 15-JAN-03
Product 2 75 1000 15-JAN-02
Product 3 50 100 15-JAN-03
Product 4 25 10000 14-JAN-03
Product 5 9.95 1234 15-JAN-04
Product 6 45 1 31-DEC-08
6 rows selected.
Thus, The SQL commands have been executed and the output was verified successfully.
24
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
Cursor:A cursor is a pointer to this context area. PL/SQL controls the context area through a
cursor. A cursor holds the rows (one or more) returned by a SQL statement. The set of rows the
cursor holds is referred to as the active set.
IMPLICIT CURSOR:
Sql%attribute name
Where attribute name can be FOUND, NOT FOUND, ISOPEN, %ROWCOUNT
EXPLICIT CURSOR:
update the customer table and increase the salary of each customer by 500
sql>SET SERVEROUTPUT ON
25
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
DECLARE
total_rowsnumber(2);
BEGIN
UPDATE customers
SET salary = salary + 500;
IF sql%notfound THEN
dbms_output.put_line('no customers selected');
ELSIF sql%found THEN
total_rows := sql%rowcount;
dbms_output.put_line( total_rows || ' customers selected ');
END IF;
END;
/
6 customers selected
+----+----------+-----+-----------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+
| 1 | Ramesh | 32 | Ahmedabad | 2500.00 |
| 2 | Khilan | 25 | Delhi | 2000.00 |
| 3 | kaushik | 23 | Kota | 2500.00 |
| 4 | Chaitali | 25 | Mumbai | 7000.00 |
| 5 | Hardik | 27 | Bhopal | 9000.00 |
26
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
| 6 | Komal | 22 | MP | 5000.00 |
+----+----------+-----+-----------+----------+
EXPLICIT CURSOR:
DECLARE
c_idcustomers.id%type;
c_namecustomers.name%type;
c_addrcustomers.address%type;
CURSOR c_customersis
SELECT id, name, address FROM customers;
BEGIN
OPEN c_customers;
LOOP
FETCH c_customersintoc_id,c_name,c_addr;
EXIT WHEN c_customers%notfound;
dbms_output.put_line(c_id||' '||c_name||' '||c_addr);
END LOOP;
CLOSE c_customers;
END;
/
1 Ramesh Ahmedabad
2 Khilan Delhi
3 kaushik Kota
4 Chaitali Mumbai
5 Hardik Bhopal
6 Komal MP
Result:
Thus the SQL / PLSQL commands have been executed and the output was verified
successfully.
27
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
SYNTAX :
1. Procedures:
Create a procedure to find minimum of two numbers
DECLARE
a number;
b number;
c number;
PROCEDURE findMin(x IN number, y IN number, z OUT number) IS
BEGIN
IF x < y THEN
28
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
z:= x;
ELSE
z:= y;
END IF;
END;
BEGIN
a:=23;
b:=45;
findMin(a, b, c);
dbms_output.put_line(' Minimum of (23, 45) : '|| c);
END;
/
Output: Minimum of (23, 45) : 23
Create a procedure to find square of a number
DECLARE
a number;
PROCEDURE squareNum(x IN OUT number) IS
BEGIN
x := x * x;
END;
BEGIN
a:=23;
squareNum(a);
dbms_output.put_line(' Square of (23): '|| a);
END;
/
Output: Square of (23): 529
Create a procedure to update the phone number to customer table
Procedure
---------
create table customer_m (cust_id int primary key,cust_name varchar2(20),cust_phone
number(4));
insert into customer_m (cust_id,cust_name) values(201,'raja');
insert into customer_m (cust_id,cust_name) values(202,NULL);
CREATE or REPLACE PROCEDURE c(ph IN NUMBER,cid IN number) IS
name varchar2(20);
BEGIN
select cust_name into name from customer_m where cust_id=cid;
IF name is NULL then
dbms_output.put_line('Name is not there');
ELSE
update customer_m set cust_phone=ph where cust_id=cid;
END IF;
29
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
END;
/
EXECUTE c(66,201);
select * from customer_m;
CUST_ID CUST_NAME CUST_PHONE
201 raja 66
202 ravi -
EXECUTE c(54,202);
2. Functions
Create a function to return the total number of CUSTOMERS in the customers table.
CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25),
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (1, 'Ramesh', 32, 'Ahmedabad', 2000.00 );
30
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
total number(2) := 0;
BEGIN
SELECT count(*) into total FROM customers;
RETURN total;
END;
/
Calling a Function
DECLARE
c number(2);
BEGIN
c := totalCustomers();
dbms_output.put_line('Total no. of Customers: ' || c);
END;
RESULT:
Thus, The SQL / PLSQL commands have been executed and the output was verified
successfully.
31
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
Ex.No.6 TRIGGERS
AIM:
To implement and execute triggers and functions using Procedural Language concepts.
TRIGGERS:
1) Trigger is a special type of procedure that the oracle executes when an insert,
modify or delete operation is performed against a given table.
2) It is a stored sub program associated with a table.
3) It is used to keep an audit trial of a table, to prevent invalid transaction, enforce
complex security authorization, to generate data automatically.
32
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
RESULT:
Thus, The SQL / PLSQL commands have been executed and the output was verified
successfully.
33
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
AIM:
To implement and execute PL/SQL Block that handles all types of exceptions in Oracle
Database using Procedural Language concepts.
SYNTAX
DECLARE
Variable declaration
BEGIN
Program Execution
EXCEPTION
Exception handling
END;
ZERO_DIVIDE EXCEPTION
SQL> BEGIN
2 DBMS_OUTPUT.PUT_LINE(1 / 0);
3 END;
4 /
BEGIN
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at line 2
------------------------------------------------------
BEGIN
DBMS_OUTPUT.PUT_LINE(1 / 0);
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Division by zero');
END;
/
Division by zero
PL/SQL procedure successfully completed.
DECLARE
a int:=10;
b int:=0;
answer int;
BEGIN
answer:=a/b;
dbms_output.put_line('the result after division is'||answer);
exception
34
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
INVALID_NUMBER EXCEPTION
create table student(g_id int , g_name varchar(20), marks int);
insert into student values(1, 'Suraj',100);
insert into student values(2, 'Praveen',97);
insert into student values(3, 'Jessie', 99);
BEGIN
INSERT INTO student(g_id)VALUES('101x');
EXCEPTION
WHEN INVALID_NUMBER THEN
DBMS_OUTPUT.PUT_LINE('Conversion of string to number failed');
END;
/
Conversion of string to number failed
PL/SQL procedure successfully completed.
NO_DATA_FOUNDEXCEPTION
DECLARE
temp varchar(20);
BEGIN
SELECT g_id into temp from student where g_name='Joseph';
exception
WHEN no_data_found THEN
dbms_output.put_line('ERROR');
dbms_output.put_line('there is no name as');
dbms_output.put_line('Joseph in Student table');
end;
TOO_MANY_ROWS:
DECLARE
temp varchar(20);
BEGIN
35
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
EXCEPTION
WHEN too_many_rows THEN
dbms_output.put_line('error trying to SELECT too many rows');
end;
OTHERS EXCEPTION
1 BEGIN
2 DBMS_OUTPUT.PUT_LINE(1 / 0);
3 EXCEPTION
4 WHEN OTHERS THEN
5 DBMS_OUTPUT.PUT_LINE('An exception occurred');
6* END;
7 /
An exception occurred
PL/SQL procedure successfully completed.
RESULT:
Thus, The SQL / PLSQL commands have been executed and the output was verified
successfully.
36
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
✓ COLLEGE
✓ PLAYERS
✓ TEAMS
✓ GAMES
✓ GROUND
✓ AWARDS
DESCRIPTION ABOUT ENTITY:
37
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
ATTRIBUTES:
PLAYERS
38
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
AWARDS
GROUN
D
TEAMS
GAMES
RELATIONSHIP:
BINARY:
• Plays
• Has
• Student of
• Receives
• Takes place
39
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
40
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
CON
NA NO.
CI TI G
TI
RANK
H N TEAMS 1 PL 1 GAMES
CON
1
T G
TAKES
NA I
1 RE
CI
COLLEG POSIT
1 1 ID
ADD GROUN NA
LI LI
AWA AR
CI STU N PLAYER N CA
PI
1 CA
A
Problem Statement: Normalization
Createacollegedatabasethatcontainsstudentid,studentname,studentcity,dateofbirth,cou
rse id, course name, duration of the course, marks and grade and their relationships.
The requirements are listedbelow:
• A college can offer one or morecourses.
• A student can enroll in one or morecourses.
• Courses can be taken by one or morestudents.
• A student can have student_id, student_name, date _of _birth andstudent_city.
• A student belongs to onecity.
• A city can have one or morestudents.
• A course can have course_id, course_nameandduration.
• When a student finishes the course, a grade and marks areawarded.
• Grades are calculated based on themarks
Below 45 – U, 45-50 – E, 50-60– D, 60-70 – C, 70-80 – B, 80-90 – A, 90-100 –S
41
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
42
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
studentid,courseid coursename
studentid,courseid duration
studentid,courseid marks
studentid,coursedgrade Full Functionaldependencies
STUDENT
RESULT
STUDENTI COURSEI MARKS GRADE
D D
THIRD NORMAL FORM
studentid,courseid grade
Thus the SQL / PLSQL commands have been executed and the output was verified
successfully.
44
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
PROBLEM STATEMENT:
The case study of library management system gives the complete information about the
library. We can enter the record of new book and retrieve the details of books available in the
library. We can issue the books to the students and maintain their records and also check how
many books are issued and stock available in the library. We can also search the books available
in the library.
Sample Code
Database:
import java.sql.Connection;
import java.sql.DriverManager;
public class DB {
public static Connection getConnection(){
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","","");
}catch(Exception e){System.out.println(e);}
return con;
}
Login:
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.awt.Color;
45
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPasswordField;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame = new AdminLogin();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public AdminLogin() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
46
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(124)
.addComponent(lblAdminLoginForm))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(19)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(lblEnterName)
.addComponent(lblEnterPassword))
.addGap(47)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
.addComponent(passwordField)
.addComponent(textField,
GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE))))
.addContainerGap(107, Short.MAX_VALUE))
.addGroup(gl_contentPane.createSequentialGroup()
47
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
.addContainerGap(187, Short.MAX_VALUE)
.addComponent(btnLogin,
GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE)
.addGap(151))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblAdminLoginForm)
.addGap(26)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblEnterName)
.addComponent(textField,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addGap(28)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblEnterPassword)
.addComponent(passwordField,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addComponent(btnLogin,
GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
.addContainerGap(80, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
}
}
Output:
Database:
Login:
48
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
Result:
Thus, The SQL / PLSQL commandsand the java GUI application have been executedand
the output was verified successfully.
49
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
PROJECT CODE:
Database Setup
create database swing_demo;
password varchar(250)
);
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
50
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
/**
*/
EventQueue.invokeLater(new Runnable() {
try {
frame.setVisible(true);
} catch (Exception e) {
51
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
e.printStackTrace();
});
/**
*/
public UserLogin() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setContentPane(contentPane);
contentPane.setLayout(null);
lblNewLabel.setForeground(Color.BLACK);
contentPane.add(lblNewLabel);
contentPane.add(textField);
52
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
textField.setColumns(10);
contentPane.add(passwordField);
lblUsername.setBackground(Color.BLACK);
lblUsername.setForeground(Color.BLACK);
contentPane.add(lblUsername);
lblPassword.setForeground(Color.BLACK);
lblPassword.setBackground(Color.CYAN);
contentPane.add(lblPassword);
btnNewButton.addActionListener(new ActionListener() {
53
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
try {
"root", "root");
st.setString(1, userName);
st.setString(2, password);
ResultSet rs = st.executeQuery();
if (rs.next()) {
dispose();
ah.setTitle("Welcome");
ah.setVisible(true);
} else {
sqlException.printStackTrace();
});
54
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
contentPane.add(btnNewButton);
contentPane.add(label);
}}
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
55
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
/**
*/
EventQueue.invokeLater(new Runnable() {
try {
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
});
public UserHome() {
/**
*/
56
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setContentPane(contentPane);
contentPane.setLayout(null);
btnNewButton.setBackground(UIManager.getColor("Button.disabledForeground"));
btnNewButton.addActionListener(new ActionListener() {
// JOptionPane.setRootFrame(null);
if (a == JOptionPane.YES_OPTION) {
dispose();
obj.setTitle("Student-Login");
obj.setVisible(true);
dispose();
obj.setTitle("Student-Login");
obj.setVisible(true);
57
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
});
contentPane.add(btnNewButton);
button.setBackground(UIManager.getColor("Button.disabledForeground"));
button.addActionListener(new ActionListener() {
bo.setTitle("Change Password");
bo.setVisible(true);
});
contentPane.add(button);
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
58
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
/**
*/
EventQueue.invokeLater(new Runnable() {
59
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
try {
} catch (Exception e) {
e.printStackTrace();
});
/**
*/
setResizable(false);
setContentPane(contentPane);
contentPane.setLayout(null);
contentPane.add(textField);
textField.setColumns(10);
60
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
btnSearch.addActionListener(new ActionListener() {
try {
System.out.println("update password");
"root", "root");
st.setString(1, pstr);
st.setString(2, name);
st.executeUpdate();
sqlException.printStackTrace();
});
61
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
contentPane.add(btnSearch);
contentPane.add(lblEnterNewPassword);
OUTPUT:
62
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
63
CS8481 DBMSLAB Department of CSE Reg. No.: 312419104055
RESULT:
64