Professional Documents
Culture Documents
OOPM Practical Journal
OOPM Practical Journal
Experiment
Name :
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
1|Page
Practical 1
Program 1 :Using Scanner Class
package Scanner_Pack;
import java.util.*;
public class Scanner_Class_2 {
2|Page
public static void main(String[] args) throws Exception
{ BufferedReader reader =new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Enter your name: ");
String name = reader.readLine();
System.out.println("Enter your age: ");
int age = Integer.parseInt(reader.readLine());
System.out.println("Enter your Id: ");
int id = Integer.parseInt(reader.readLine());
System.out.println("Enter your Salary: ");
float Salary= Float.parseFloat(reader.readLine());
//long l= Long.parseLong(reader.readLine());
//double d= Double.parseDouble(reader.readLine());
//String s=reader.readLine();
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("ID: " + id);
System.out.println("Salary: " + Salary);
}
}
byte b=10;
short s=20;
int i=30;
long l=40;
float f=50.0F;
double d=60.0D;
char c='a';
boolean b2=true;
//Printing objects
System.out.println("---Printing object values---");
System.out.println("Byte object: "+byteobj);
System.out.println("Short object: "+shortobj);
System.out.println("Integer object: "+intobj);
System.out.println("Long object: "+longobj);
System.out.println("Float object: "+floatobj);
System.out.println("Double object: "+doubleobj);
System.out.println("Character object: "+charobj);
System.out.println("Boolean object: "+boolobj);
//Printing primitives
System.out.println("---Printing primitive values---");
System.out.println("byte value: "+bytevalue);
System.out.println("short value: "+shortvalue);
System.out.println("int value: "+intvalue);
System.out.println("long value: "+longvalue);
System.out.println("float value: "+floatvalue);
System.out.println("double value: "+doublevalue);
System.out.println("char value: "+charvalue);
System.out.println("boolean value: "+boolvalue);
}
}
Conclusion :
Studied use of scanner class and Buffered reader class
4|Page
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name : __________________________________________________________
Title of Experiment : Use of if..else , switch..case , for loop , for each loop , while loop and
do..while loop.
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
5|Page
Practical 2
Programs on if , if else
Program 1 : Find the Largest of three numbers using for loop
package if_else;
import java.util.*;
6|Page
System.out.println("Third Number is Larger than other
Two Numbers :" + Num3);
}
myObj.close();
package if_else;
import java.util.*;
7|Page
Programs on switch case
Program :Using int type data in switch case
package SwitchCase;
package SwitchCase;
8|Page
switch (operator)
{ // "char" selector
case '+': // "char" value
result = num1 + num2;
break;
case '-':
result = num1 - num2;
break;
case '*':
result = num1 * num2;
break;
case '/':
if (num2 !=0)
{
result = num1 / num2;
}
else
System.out.println("Divide by zero Error");
break;
default:
System.out.println("Unknown operator");
}
}
}
package SwitchCase;
switch (day) {
case SUNDAY:
System.out.println( " Day is : Sunday ");
break;
case MONDAY:
System.out.println( " Day is : Monday ");
break;
case TUESDAY:
9|Page
System.out.println( " Day is : Tuesday
"); break;
case WEDNESDAY:
System.out.println( " Day is : Wednesday
"); break;
default:
System.out.println( " Day is not in the list ");
break;
}
}
}
package SwitchCase;
10 | P a g e
Programs on while Loop
Program1 : To find count of Digits and Sum of Digits of a given Number
package whileLoop;
import java.util.Scanner;
11 | P a g e
Program 2 : To find factorial of a given Number
package whileLoop;
import java.util.*;
System.out.println("Factorial: " +
fact); myObj.close();
}
}
12 | P a g e
Program 3 : To find a given Number is Armstrong Number or Not.
package whileLoop;
import java.util.Scanner;
import java.lang.Math;
/ Numerical input
int temp,count=0;
temp=Num;
Num=Num/10;
count++;
int digit,sum=0;
13 | P a g e
Num=temp;
digit=Num % 10;
Num=Num/10;
if (sum==temp)
else
myObj.close();
14 | P a g e
Programs using do while loop
Program 1 : Find the multiplication table of a given number
package doWhile;
import java.util.Scanner;
myObj.close();
package doWhile;
import java.util.Scanner;
15 | P a g e
Scanner myObj = new Scanner(System.in);
16 | P a g e
Program on for loop
Program 1 : Sum of N Natural Numbers using for loop
package forLoop;
import java.util.Scanner;
}
System.out.println( "Sum of first " + Num + "
Natural Numbers is : " + sum );
myObj.close();
}
}
package forLoop;
import java.util.Scanner;
17 | P a g e
// Numerical input
int Num = myObj.nextInt();
int fact = 1;
for (int i=1 ; i <= Num ; i++)
{
fact=fact*i;
System.out.println("Factorial: " +
fact); myObj.close();
package forLoop;
import java.util.Scanner;
18 | P a g e
}
}
Program 4 : To check whether given number is prime or not using for loop
package forLoop;
import java.util.Scanner;
if (primeFlag==false)
{
System.out.println(Num + " is Not Prime " );
}
else
{
System.out.println(Num + " is Prime " );
}
myObj.close();
19 | P a g e
Program 5 : To find prime numbers in a given range using for loop
package forLoop;
import java.util.Scanner;
/*
if (primeFlag==false)
{
System.out.println(Num + " is Not Prime " );
}
else
{
System.out.println(Num + " is Prime " );
}
*/
20 | P a g e
if (primeFlag == true)
{
System.out.println(Num);
}
myObj.close();
}
}
}
21 | P a g e
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name : __________________________________________________________
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
22 | P a g e
Practical 3
Program on class and objects
package AreaPerimeter;
import java.util.*;
class RectangleNew
{
float length, breadth;
void setValue(float l, float b)
{
length = l;
breadth = b;
}
/ get area of rectangle
float findArea()
{
return (length * breadth);
}
/ Method to calculate the Perimeter of
Rectangle float findPerimeter()
{
return (2 * (length + breadth));
}
}
23 | P a g e
System.out.println("Perimeter of rectangle is : "+
objNew.findPerimeter());
myObj.close();
}
}
Programs on Constructor
Program 1 : Enter and print student data using parameterized constructor.
package studentDataUsingConstructor; //parameterized
constructor import java.io.*;
class StudentDetail
{
int roll,age;
String Name;
StudentDetail(int p, String q, int r)
{
roll = p;
Name=q;
age=r;
}
void ShowData()
{
System.out.println("Roll Number : "+roll);
System.out.println("Students Name : "+Name);
System.out.println("Hindi Marks : "+age);
}
}
24 | P a g e
RollNumber = Integer.parseInt(read);
System.out.println("Enter Name of the Student : ");
Name=Br.readLine();
System.out.println("Enter Age of the student : ");
read=Br.readLine();
Age=Integer.parseInt(read);
StudentDetail std= new StudentDetail(RollNumber,Name,Age);
System.out.println("Details of the Student Entered are :");
std.ShowData();
Br.close();
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
//Or
//import java.io. * ;
class RectangleShape
RectangleShape(int l, int b)
length = l;
25 | P a g e
breadth = b;
void getArea()
void getPerimeter()
BufferedReader br = new
BufferedReader(new InputStreamReader(System.in));
Integer.parseInt(strLength);
Integer.parseInt(strBreadth);
26 | P a g e
RectangleShape rs = new RectangleShape(length, breadth);
rs.getArea();
rs.getPerimeter();
br.close();
Conclusion:
Studied use of constructor.
27 | P a g e
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name :
Experiment : Inheritance
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
28 | P a g e
Practical 4
Inheritance
class A {
void msgA(){
class B extends A {
void msgB(){
A objA=new A();
objA.msgA();
B objB=new B();
objB.msgA();
objB.msgB();
class A{
void msgA(){
System.out.println("Hello");
29 | P a g e
}
class B extends A {
void msgB(){
System.out.println("Welcome");
class C extends B{
void msgC(){
System.out.println(“Students");
A objA=new A();
objA.msgA();
B objB=new B();
objB.msgA();
objB.msgB();
C objC=new C();
objC.msgA();
objB.msgB();
objC.msgC();
class A{
void msgA(){
30 | P a g e
System.out.println("Hello");
class B extends A {
void msgB(){
System.out.println("Welcome");
class C extends A{
void msgC(){
System.out.println(“Students");
A objA=new A();
objA.msgA();
B objB=new B();
objB.msgA();
objB.msgB();
C objC=new C();
objC.msgA();
objC.msgC();
Experiment
Name : __________________________________________________________
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
32 | P a g e
Practical 5
Encapsulation
Aim : To implement Encapsulation for Employee data
package TestEncapsulation;
class Employee {
private String name;
private String idNum;
private int age;
33 | P a g e
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name : __________________________________________________________
Experiment : Polymorphism
Title of Experiment : Programs on Method Overloading ,Method Overriding , Run time and
Compile time Polymorphism
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
34 | P a g e
Practical 6
Polymorphism
Program 1:
package CompilePolymorphism;
package RuntimePolymorphismTest;
35 | P a g e
void famousfor(){
System.out.println("It is Famous for Hadimba Temple and
adventure sports");
}
}
A.location();
M.location();
A.famousfor();
M.famousfor();
A.location();
Mu.location();
A.famousfor();
Mu.famousfor();
36 | P a g e
A.location();
G.location();
A.famousfor();
G.famousfor();
}
}
package RuntimePolymorphismTest;
//Inherited class
class Child1 extends Parent1 {
/ This method overrides show() of Parent
@Override
void show()
{
System.out.println("Child's show()");
}
}
}
}
Conclusion: Studied concept of Polymorphism i.e. run time and compile time polymorphism.
37 | P a g e
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name : __________________________________________________________
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
38 | P a g e
Practical 7
Assertion and Abstration
Aim : To use Assertion in Java
Step 1 : Type below Program in Notepad
import java.util.Scanner;
class AssertionExample{
public static void main( String args[] ){
Step 2 : Save Program with AssertionExample.java in the same folder used by java compiler
or JDK. Select type of file as all files.
Output 1 :
35 Voter is eligible
Output 2 :
39 | P a g e
Aim : To do abstraction using 1) abstract class 2) interface
Example 1 :
package AbstractClassTest1;
Example 2 :
package AbstractClassTest1;
40 | P a g e
int Rate; //data abstraction
abstract int getInterestRate();//control abstraction
}
//concrete class
class ICICI extends Bank {
int Rate=7;
int getInterestRate(){ //method overriding
System.out.println("ICICI rate 7%");
return 7;
}
}
2) Using interface.
package AbstractClassTest1;
interface I1{
public void show();
}
41 | P a g e
public void show() {
System.out.println ("Interface test");
}
}
package AbstractClassTest1;
interface M1{
public void show1() ;
}
interface M2{
public void show2() ;
}
42 | P a g e
MT.show1();
MT.show2();
}
}
Conclusion :
Studied use of assert class
Studied use of abstract class
Studied use of interface.
43 | P a g e
Second year: Computer Engineering
Experiment
Name : __________________________________________________________
Experiment : Arrays
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
44 | P a g e
Practical 8
Arrays
Program 1: Write a program to calculate total of 1D array elements
using Anonymous Array
//Anonymous Array 1D
package ArraysPackage;
/ using for-each
loop for (int i : a)
total = total + i;
45 | P a g e
Program 2: Write a program to calculate total of 2D array elements
using Anonymous Array
//Anonymous Array 2D
package ArraysPackage;
Program 3 : Find the element with maximum value and minimum value from
the 1D array.
package ArraysPackage;
46 | P a g e
public class ArrayMaxMin {
package ArraysPackage;
import java.util.Scanner;
public class ArrayWithScanner {
47 | P a g e
if (arrS[i] > arrS[j])
{
tmp = arrS[i];
arrS[i] = arrS[j];
arrS[j] = tmp;
}
}
//prints the sorted element of the array
System.out.println(arrS[i]); }
}
}
package ArraysPackage;
import java.util.Arrays;
package ArraysPackage;
48 | P a g e
{9,11,5,4}, { 6,
0, 13, 17 },
{ 7, 21, 14, 15 } };
System.out.println("Entered Array is");
for (int i = 0; i < matrix4.length; i++) {
for (int j = 0; j < matrix4[i].length; j++) {
System.out.print( matrix4[i][j] + "\t");
}
System.out.println();
}
package ArraysPackage;
49 | P a g e
}
System.out.println();
}
System.out.println("Entered Array B is");
for (int i = 0; i < B.length; i++) {
for (int j = 0; j < B[i].length; j++) {
System.out.print( B[i][j] + "\t");
}
System.out.println();
}
package ArraysPackage;
package ArraysPackage;
51 | P a g e
Program 8B : Write a program to copy a 1D array using
Arrays.copyof() method.
/*
public static int[] copyOf(int[] original, int
newLength) Parameters: Original array
Length of the array to get copied.
*/
package ArraysPackage;
import java.util.Arrays;
}
}
Conclusion : Studied Arrays class and also to use 1D Array and 2D arrays.
52 | P a g e
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name : __________________________________________________________
Experiment : Strings
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
53 | P a g e
Practical 9
Strings
Program 1 : To check string is palindrome or not.
package StringPrograms;
54 | P a g e
Program 2 : To check string is an anagram or not.
package StringPrograms;
import java.util.Arrays;
55 | P a g e
Program 3 : To use StringBuffer
package StringPrograms;
56 | P a g e
Program 4 : To use StringBuilder
package StringPrograms;
Conclusion :
Studied Basic use of String class ,StringBuffer and String Builder class
57 | P a g e
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name : __________________________________________________________
Title of Experiment : GUI using AWT (Association & Inheritance) & swing (Association & Inheritance).
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
58 | P a g e
Practical 10
AWT/ Swing Practical
AWTExample1() {
setVisible(true);
59 | P a g e
Program 2 :AWT using Association
import java.awt.*; // importing Java AWT class
class AWTExample2 {
AWTExample2() {
Frame f = new Frame(); // creating a Frame
f.add(l);
f.add(t);
height f.setSize(400,300);
60 | P a g e
public static void main(String args[]) {
JFrame f;
Simple2(){
b.setBounds(130,100,100, 40);
setSize(400,500);
setLayout(null);
setVisible(true);
new Simple2();
61 | P a g e
Program 4 :Swing by Asociation
import javax.swing.*;
JFrame f;
Simple(){
b.setBounds(130,100,100, 40);
new Simple();
62 | P a g e
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name : __________________________________________________________
Experiment : Applets
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
63 | P a g e
Practical 11
Applets
import java.applet.*;
import java.awt.*;
String str;
str=getParameter("pname");
if (str == null)
HTML Code
<html>
</applet>
</html
Conclusion : Created applet and HTML code for running the applet in browser.
64 | P a g e
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name : __________________________________________________________
Title of Experiment : WAP for Exception Handling using tyr..catch ,try..catch..finally blocks & throw ,throws
keywords
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
65 | P a g e
Practical 12
Exception Handling
Java try...catch block
The try-catch block is used to handle exceptions in Java.
try {
// code
catch(Exception e) {
// code
Place the code that might generate an exception inside the try block. Every try block is
followed by a catch block.When an exception occurs, it is caught by the catch block. The catch
block cannot be used without the try block.
The finally block is optional. And, for each try block, there can be only one finally block.
try {
//code
/ catch block
finally {
66 | P a g e
}
exception try {
int divideByZero = 5 / 0;
catch (ArithmeticException e)
e.getMessage());
finally {
Output :
ArithmeticException => / by zero
The Java throw keyword is used to explicitly throw a single exception.When we throw an
exception, the flow of the program moves from the try block to the catch block.
67 | P a g e
The throws keyword is used to declare the type of exceptions that might occur within the
method. It is used in the method declaration.
divideByZero();
Output :
Exception in thread "main" java.lang.ArithmeticException: Trying to divide by 0
at Main.divideByZero(Main.java:5)
at Main.main(Main.java:9)
68 | P a g e
else {
Output :
69 | P a g e
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name : __________________________________________________________
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
70 | P a g e
Practical 13
String str1;
MyException(String str2) {
str1=str2;
try{
catch(MyException exp)
{ System.out.println("Catch Block")
; System.out.println(exp) ;
71 | P a g e
}
Output:
72 | P a g e
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name : __________________________________________________________
Experiment : JDBC
Title of Experiment : Program for connecting MySQL database to Java program using JDBC
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
73 | P a g e
Practical 14
JDBC
Aim : To Crate Login Database using MySQL and create connection in Java JDBC.
Database Setup
MySQL Statements
• Make sure that you have installed the MySQL server on your machine.
• Create a LoginTB table in the above-created database with the following SQL statement:
CREATE TABLE LoginTB ( Login_Level int NOT NULL, LName varchar(50) NOT
NULL, Password varchar(15));
• Insert a record in the above table with the following SQL statement.
• Insert a record in the above table with the following SQL statement.
Java Program
import java.sql.*;
class MysqlCon{
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(
74 | P a g e
"jdbc:mysql://localhost:3306/LoginDB","root",”");
while(rs.next())
con.close();
}catch(Exception e){
System.out.println(e);
Conclusion : Created JDBC Connection .Read data from MySQL Database successfully.
75 | P a g e
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name : __________________________________________________________
Experiment : Multithreading.
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
76 | P a g e
77 | P a g e
Practical 15
Program on MultiThreading
// Main Class
public class Multithread {
public static void main(String[] args)
{
int n = 8; // Number of threads
for (int i = 0; i < n; i++) {
MultithreadingDemo object
= new MultithreadingDemo();
object.start();
}
}
}
Output
Thread 15
is running
Thread 14
is running
Thread 16
is running
Thread 12
is running
Thread 11
is running
Thread 13
is running
Thread 18
is running
Thread 17
is running
Conclusion : Studied Multithreading .
78 | P a g e
Second year: Computer Engineering
[Skill Lab : OOPs with Java]
Experiment
Name : __________________________________________________________
Title of Experiment : GUI Application for Login using swing and JDBC.
W.I.E.E.C.T
Experiment/Assignment
Concept 02
Execution/Performance 04
Viva 04
Total 10
79 | P a g e
Practical 16
Program : GUI Application for Login Panel using swing ,AWT and JDBC
Code :
package loginform;
/* @author SVKADAM */
//import java.sql.Connection;
//import java.sql.DriverManager;
//import java.sql.ResultSet;
//import java.sql.SQLException;
//import java.sql.Statement;
//or
import java.sql.*;
80 | P a g e
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
public LoginDemo() {
initComponents();
WARNING: Do NOT modify this code. The content of this method is always
regenerated by the Form Editor. */
@SuppressWarnings("unchecked")
new javax.swing.JButton();
81 | P a g e
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
LblUserName.setText("User Name");
getContentPane().add(LblUserName);
LblPassword.setText("Password");
getContentPane().add(LblPassword); LblPassword.setBounds(28,
java.awt.Font("Consolas", 1, 14));
TxtUserName.addActionListener(new
java.awt.event.ActionListener() {
TxtUserNameActionPerformed(evt);
});
getContentPane().add(TxtUserName);
82 | P a g e
TxtPassword.setBackground(new java.awt.Color(0, 204, 255));
TxtPassword.setFont(new java.awt.Font("Consolas", 1, 14
getContentPane().add(TxtPassword);
BtnLogin.setText("Login");
BtnLogin.setToolTipText("");
BtnLogin.addActionListener(new java.awt.event.ActionListener()
BtnLoginActionPerformed(evt);
});
getContentPane().add(BtnLogin); BtnLogin.setBounds(26,
java.awt.Font("Consolas", 1, 18));
BtnReset.setText("Reset");
BtnReset.addActionListener(new java.awt.event.ActionListener()
BtnResetActionPerformed(evt);
});
getContentPane().add(BtnReset);
83 | P a g e
BtnExit.setBackground(new java.awt.Color(0, 153, 255));
BtnExit.setText("Exit");
BtnExit.addActionListener(new java.awt.event.ActionListener() {
BtnExitActionPerformed(evt);
});
getContentPane().add(BtnExit);
pack();
}// </editor-fold>
String UName =
TxtPassword.getText(); Connection
84 | P a g e
connection=DriverManager.getConnection (DB_URL,DB_USER,DB_PASSWD);
statement=connection.createStatement();
while(resultSet1.next()){
System.out.printf("%s %s %d",
resultSet1.getString(1),
resultSet1.getString(2),
resultSet1.getInt(3));
System.out.println("\n");
pst.setString(1,UName);
pst.setString(2,PWD);
resultSet2 =pst.executeQuery();
while(resultSet2.next()){
System.out.printf("%s %s %d",
resultSet2.getString(1),
resultSet2.getString(2),
resultSet2.getInt(3));
System.out.println("\n");
if (resultSet2.getString(1).equals(UName) &&
resultSet2.getString(2).equals(PWD)){
System.out.println("Welcome");
85 | P a g e
}
else{
}catch(SQLException e)
{ JOptionPane.showMessageDialog(null,
e);
finally{
try {
resultSet1.close();
statement.close();
connection.close();
/ System.out.println("Welcome");
/ }
here: TxtUserName.setText(null);
86 | P a g e
TxtPassword.setText(null);
here: System.exit(0);
try {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
87 | P a g e
java.util.logging.Logger.getLogger(LoginDemo.class.getName()).log(java .util.logging.Level.SEVERE,
null, ex);
java.util.logging.Logger.getLogger(LoginDemo.class.getName()).log(java .util.logging.Level.SEVERE,
null, ex);
java.util.logging.Logger.getLogger(LoginDemo.class.getName()).log(java .util.logging.Level.SEVERE,
null, ex);
java.util.logging.Logger.getLogger(LoginDemo.class.getName()).log(java .util.logging.Level.SEVERE,
null, ex);
//</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
new LoginDemo().setVisible(true);
});
88 | P a g e
private javax.swing.JButton BtnLogin;
Database Setup
MySQL Statements
• Make sure that you have installed the MySQL server on your machine.
• Create a LoginTB table in the above-created database with the following SQL statement:
CREATE TABLE LoginTB ( Login_Level int NOT NULL, LName varchar(50) NOT
NULL, Password varchar(15));
• Insert a record in the above table with the following SQL statement.
• Insert a record in the above table with the following SQL statement.
Conclusion : Created GUI Application for Login using swing and JDBC.
89 | P a g e