0% found this document useful (0 votes)
4 views10 pages

Java

java
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views10 pages

Java

java
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING


PBLJ LAB ASSIGNMENT

Student Name: Shivansh Rattan UID: 22BCS16351


Branch: BE CSE Section/Group: 22BCS_IOT_610-B
Semester: 6th Date of Performance:18/04/2025
Subject Name: PBLJ Subject Code: 22CSH-359
SET-1
PROBLEM 1:
Online Banking System:
Objective: Develop a secure and functional online banking system using Java. Features: User
authentication, account management, fund transfers, transaction history, and security measures.
Skills: Java programming, database management (e.g., MySQL), security implementation, and
web development.

Code Implementation:
package bank;

import java.awt.Desktop; import java.awt.PopupMenu; import static


java.awt.SystemColor.desktop; import javax.swing.JDesktopPane;
import javax.swing.JFrame; import javax.swing.JInternalFrame; public
class mainmenu extends javax.swing.JFrame { private PopupMenu
internalFrame;

public mainmenu() { initComponents();


}
initComponents() {
jMenuItem1 = new javax.swing.JMenuItem(); jDesktopPane1 = new
javax.swing.JDesktopPane(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 =
new javax.swing.JMenu(); jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu();

jMenuItem4 = new javax.swing.JMenuItem(); jMenuItem5 = new


javax.swing.JMenuItem(); jMenu3 = new javax.swing.JMenu(); jMenuItem6 =
new javax.swing.JMenuItem(); jMenu4 = new javax.swing.JMenu(); jMenuItem7
= new javax.swing.JMenuItem(); jMenu5 = new javax.swing.JMenu();
jMenuItem8 = new javax.swing.JMenuItem(); jMenu6 = new
javax.swing.JMenu(); jMenuItem9 = new javax.swing.JMenuItem();
jMenuItem1.setText("jMenuItem1");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setPreferredSize(new java.awt.Dimension(1366, 768)); javax.swing.GroupLayout
jDesktopPane1Layout = new javax.swing.GroupLayout(jDesktopPane1);
jDesktopPane1.setLayout(jDesktopPane1Layout);
jDesktopPane1Layout.setHorizontalGroup(
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGap(0, 823, Short.MAX_VALUE)
);
jDesktopPane1Layout.setVerticalGroup(
jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGap(0, 764, Short.MAX_VALUE)
);
jMenu1.setText("File");

jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.Key
Event.VK_BACK_ SPACE, 0)); jMenuItem2.setText("Customer");
jMenuItem2.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2);

jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.Key
Event.VK_B, java.awt.event.InputEvent.SHIFT_DOWN_MASK));
jMenuItem3.setText("Account");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem3);

jMenuBar1.add(jMenu1); jMenu2.setText("Transaction");
jMenuItem4.setText("Withdraw"); jMenuItem4.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem4);
jMenuItem5.setText("Deposit");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
jMenu2.add(jMenuItem5); jMenuBar1.add(jMenu2);
jMenu3.setText("Transfer");
jMenu3.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent
evt) { jMenu3ActionPerformed(evt);
}
});
jMenuItem6.setText("AccountToAccount"); jMenuItem6.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem6); jMenuBar1.add(jMenu3); jMenu4.setText("Report");
jMenuItem7.setText("Customer Report"); jMenuItem7.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem7ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem7); jMenuBar1.add(jMenu4);

jMenu5.setText("Balance");

jMenuItem8.setText("Balance Check"); jMenuItem8.addActionListener(new


java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem8ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem8); jMenuBar1.add(jMenu5); jMenu6.setText("Admin");
jMenuItem9.setText("Account Creation"); jMenuItem9.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem9ActionPerformed(evt);
}
});
jMenu6.add(jMenuItem9); jMenuBar1.add(jMenu6);
setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jDesktopPane1)
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
.addGap(69, 69, 69))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jDesktopPane1)
.addContainerGap())
);

pack();
}// </editor-fold>

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {


customer cus = new customer();
jDesktopPane1.add(cus); cus.setVisible(true);

} private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt)


{ // TODO add your handling code here:
account cus = new account(); jDesktopPane1.add(cus); cus.setVisible(true);

} private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt)


{ // TODO add your handling code here:
withdraw cus = new withdraw(); jDesktopPane1.add(cus); cus.setVisible(true);

} private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt)


{ // TODO add your handling code here:
deposit cus = new deposit(); jDesktopPane1.add(cus); cus.setVisible(true);

private void jMenu3ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

}
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here: transfer cus1 = new transfer();
jDesktopPane1.add(cus1); cus1.setVisible(true);

private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) { //


TODO add your handling code here: cusreport cus1 = new cusreport();
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
jDesktopPane1.add(cus1); cus1.setVisible(true); } private void
jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add
your handling code here: balance cus1 = new balance();
jDesktopPane1.add(cus1); cus1.setVisible(true);

} private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt)


{ // TODO add your handling code here:

user1 cus1 = new user1(); jDesktopPane1.add(cus1); cus1.setVisible(true);


} try { for (javax.swing.UIManager.LookAndFeelInfo info
:
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName()); break;

}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(mainmenu.class.getName()).log(java.util.logging.
Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(mainmenu.class.getName()).log(java.util.logging.
Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(mainmenu.class.getName()).log(java.util.logging.
Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(mainmenu.class.getName()).log(java.util.logging.
Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new mainmenu().setVisible(true);
}
});
}
// Variables declaration - do not modify private javax.swing.JDesktopPane
jDesktopPane1; private javax.swing.JMenu jMenu1; private javax.swing.JMenu
jMenu2; private javax.swing.JMenu jMenu3; private javax.swing.JMenu
jMenu4; private javax.swing.JMenu jMenu5; private javax.swing.JMenu
jMenu6; private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem
jMenuItem2; private javax.swing.JMenuItem jMenuItem3; private
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
javax.swing.JMenuItem jMenuItem4; private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6; private javax.swing.JMenuItem
jMenuItem7; private javax.swing.JMenuItem jMenuItem8; private
javax.swing.JMenuItem jMenuItem9;
// End of variables declaration

OUTPUT:

Learning Outcomes:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
1. Apply Java programming and MySQL to develop a functional, data-driven banking
system.
2. Implement secure authentication and data protection techniques.
3. Develop and manage core banking features like fund transfers and transaction history.

PROBLEM 2:
Hospital Management System:
Objective: Build a system to manage patient records, appointments, and medical staff in a
hospital.
Features: Patient registration, appointment scheduling, medical staff management, and
recordkeeping.
Skills: Java programming, database integration (e.g., MongoDB), user interface design, and
system testing.

Code Implementation:
ADMIN LOGIN FILE:
Private String user;
private String pass;

@Override protected void doPost(HttpServletRequest request,


HttpServletResponse response) throws ServletException, IOException
{ PrintWriter pw = response.getWriter(); try {
String userp = request.getParameter("your_name");
String passp = request.getParameter("your_pass");
Connection con = DatabaseConnection.initializeDatabase();

String s = "select *from adminreg";


Statement st = con.createStatement();
ResultSet rs
= st.executeQuery(s); while
(rs.next()) { user = rs.getString(1);
pass
= rs.getString(2);
} if (userp.equals(user) && passp.equals(pass)) {
pw.println("<script
type=\"text/javascript\">"); pw.println("alert('Login
Successfully..!');"); pw.println("window.location.href =
\"AdminHome.jsp\";");
pw.println("</script>");
//RequestDispatcher rd = request.getRequestDispatcher("AdminHome.jsp");
//rd.forward(request, response);
} else {
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
pw.println("<script type=\"text/javascript\">"); pw.println("alert('Username or
Password is Incorrect..!');"); pw.println("window.location.href =
\"index.jsp\";"); pw.println("</script>");
//RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
//rd.include(request, response);
}
} catch (Exception e) {

USER LOGIN FILE:


package Controller;

import Database.DatabaseConnection; import


java.io.IOException; import
java.io.PrintWriter; import java.sql.Connection;
import java.sql.ResultSet; import
java.sql.Statement; import
javax.servlet.ServletException; import
javax.servlet.annotation.WebServlet; import
javax.servlet.http.HttpServlet; import
javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
*
* @author Admin
*/
@WebServlet("/UserLogin") public class
UserLogin extends HttpServlet {

private String user; private


String pass;

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { PrintWriter pw = response.getWriter();
try {
String userp = request.getParameter("username");
String passp = request.getParameter("password");
Connection con = DatabaseConnection.initializeDatabase();
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
String s = "select *from login";
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(s);
while (rs.next()) { user =
rs.getString(1); pass
= rs.getString(2);
}
if (userp.equals(user) && passp.equals(pass)) { pw.println("<script
type=\"text/javascript\">"); pw.println("alert('Login Successfully..!');");
pw.println("window.location.href = \"UserHome.jsp\";");
pw.println("</script>");
//RequestDispatcher rd = request.getRequestDispatcher("UserHome.jsp");
//rd.forward(request, response);
} else { pw.println("<script type=\"text/javascript\">"); pw.println("alert('Username
or Password is Incorrect..!');"); pw.println("window.location.href =
\"index.jsp\";"); pw.println("</script>");
// RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
// rd.include(request, response);
}
} catch (Exception e) {

DATABASE CONNECTIVITY FILE:


package Database;

/**
*
* @author Admin
*/ import java.sql.Connection;
import
java.sql.DriverManager;
import java.sql.SQLException;

// This class can be used to initialize the database connection


public class DatabaseConnection {
public static Connection initializeDatabase()
throws SQLException, ClassNotFoundException
{
// Initialize all the information regarding
// Database Connection
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
String dbDriver = "com.mysql.jdbc.Driver";
String dbURL = "jdbc:mysql://localhost:3306/";
// Database name to access
String dbName = "hospital";
String dbUsername = "root";
String dbPassword = "root";

Class.forName(dbDriver);
Connection con =
DriverManager.getConnection(dbURL+dbName,dbUsername,dbPassword);
return con;
}
}

OUTPUT:

Learning Outcomes:
1. Utilize Java and MongoDB to develop a structured system for managing hospital data.
2. Design user interfaces for patient registration, appointments, and staff management.
3. Perform system testing to ensure reliable record-keeping and scheduling operations.

You might also like