0% found this document useful (0 votes)
20 views8 pages

Varun Contextual Hands On

Uploaded by

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

Varun Contextual Hands On

Uploaded by

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

-------------For Account Class --------------------------------------------

package com.theVarunContextualHandsOn;

public class Account {


private int account_no;
private String account_type;
private int cust_id;
private int total_balance;

public Account() {
}

public Account(int account_no, String account_type, int cust_id, int


total_balance) {
this.account_no = account_no;
this.account_type = account_type;
this.cust_id = cust_id;
this.total_balance = total_balance;
}

public int getAccount_no() {


return account_no;
}

public void setAccount_no(int account_no) {


this.account_no = account_no;
}

public String getAccount_type() {


return account_type;
}

public void setAccount_type(String account_type) {


this.account_type = account_type;
}

public int getCust_id() {


return cust_id;
}

public void setCust_id(int cust_id) {


this.cust_id = cust_id;
}

public int getTotal_balance() {


return total_balance;
}

public void setTotal_balance(int total_balance) {


this.total_balance = total_balance;
}

@Override
public String toString() {
return "Account{" +
"account_no=" + account_no +
", account_type='" + account_type + '\'' +
", cust_id=" + cust_id +
", total_balance=" + total_balance +
'}';
}
}

-----------------------------------------------------------------------------
--------------------------------------------Connection factory
Class---------------------------------------
package com.theVarunContextualHandsOn;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;

public class ConnectionFactory {


private static Connection connection = null;

private ConnectionFactory() {

public static Connection getConnection() {

if (connection == null) {
ResourceBundle resourceBundle = ResourceBundle.getBundle("dbConfig");
// String url = "jdbc:mysql://localhost:3306/bankapp";
// String username = "root";
// String password = "root";
String url = resourceBundle.getString("url");
String username = resourceBundle.getString("username");
String password = resourceBundle.getString("password");
try {
connection = DriverManager.getConnection(url, username, password);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
return connection;
}
}

-----------------------------------------------------------------------------------
--------
-------------------------------------------Customer
Class-------------------------------------------
package com.theVarunContextualHandsOn;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class Customer {
@Id
private int cust_id;
private String cust_name;
private String cust_email;

public Customer() {
}

public Customer(int cust_id, String cust_name, String cust_email) {


this.cust_id = cust_id;
this.cust_name = cust_name;
this.cust_email = cust_email;
}

public int getCust_id() {


return cust_id;
}

public void setCust_id(int cust_id) {


this.cust_id = cust_id;
}

public String getCust_name() {


return cust_name;
}

public void setCust_name(String cust_name) {


this.cust_name = cust_name;
}

public String getCust_email() {


return cust_email;
}

public void setCust_email(String cust_email) {


this.cust_email = cust_email;
}

@Override
public String toString() {
return "Customer{" +
"cust_id=" + cust_id +
", cust_name='" + cust_name + '\'' +
", cust_email='" + cust_email + '\'' +
'}';
}
}
-----------------------------------------------------------------------------------
--------
----------------------------------------Customer Dao Interface
------------------------------------------------
package com.theVarunContextualHandsOn;

public interface CustomerDao {


void addCustomer(Customer customer);
void updateCustomer(Customer customer);
void deleteCustomer(Customer customer);
void amt_withdrawn(TransactionInfo transactionInfo);
void amt_deposit(TransactionInfo transactionInfo);
void total_balance(Account account);
}
-----------------------------------------------------------------------------------
----
-----------------------------------Customer Dao Factory
Class-----------------------------------------------------
package com.theVarunContextualHandsOn;

public class CustomerDaoFactory {


private static CustomerDao customerDao ;

private CustomerDaoFactory() {
}
public static CustomerDao getCustomerDao(){
if (customerDao == null){
customerDao = new CustomerDaoImpl();
}
return customerDao;
}

}
-----------------------------------------------------------------------------------
-------------------
----------------------------------------
CustomerDaoImpl--------------------------------------------------------------------
--
package com.theVarunContextualHandsOn;

public class CustomerDaoImpl implements CustomerDao{


@Override
public void addCustomer(Customer customer) {

@Override
public void updateCustomer(Customer customer) {

@Override
public void deleteCustomer(Customer customer) {

@Override
public void amt_withdrawn(TransactionInfo transactionInfo) {

@Override
public void amt_deposit(TransactionInfo transactionInfo) {

@Override
public void total_balance(Account account) {

}
}
-----------------------------------------------------------------------------------
----------------
--------------------------------------------------dbCinfig.properties
file------------------------------------------
url=jdbc:mysql://localhost:3306/bankapp
username=root
password=root
-----------------------------------------------------------------------------------
----------------------
-------------------------------------------------------EmployeeInfo
Class--------------------------------------------------
package com.theVarunContextualHandsOn;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class EmployeeInfo {
@Id
int emp_id;
String emp_name;
String emp_email;

public EmployeeInfo() {
}

public EmployeeInfo(int emp_id, String emp_name, String emp_email) {


this.emp_id = emp_id;
this.emp_name = emp_name;
this.emp_email = emp_email;
}

public int getEmp_id() {


return emp_id;
}

public void setEmp_id(int emp_id) {


this.emp_id = emp_id;
}

public String getEmp_name() {


return emp_name;
}

public void setEmp_name(String emp_name) {


this.emp_name = emp_name;
}

public String getEmp_email() {


return emp_email;
}

public void setEmp_email(String emp_email) {


this.emp_email = emp_email;
}

@Override
public String toString() {
return "EmployeeInfo{" +
"emp_id=" + emp_id +
", emp_name='" + emp_name + '\'' +
", emp_email='" + emp_email + '\'' +
'}';
}
}
-----------------------------------------------------------------------------------
--------
---------------------------------------------------------
EmployeeInfoDao-------------------------------------------------------
package com.theVarunContextualHandsOn;

public interface EmployeeInfoDao {


void addEmployee(EmployeeInfo employeeInfo);
void updateEmployee(EmployeeInfo employeeInfo);
void deleteEmployee(int id);
void viewCustomerDetails(Customer customer);
void viewTransactions(TransactionInfo transactionInfo);
}
-----------------------------------------------------------------------------------
-------------------------------
--------------------------------------------------------EmployeeInfoDaoFactory
Class---------------------------------------------------------
package com.theVarunContextualHandsOn;

public class EmployeeInfoDaoFactory {


private static EmployeeInfoDao employeeInfoDao;

private EmployeeInfoDaoFactory() {

public static EmployeeInfoDao getEmployeeInfoDao() {


if (employeeInfoDao == null) {
employeeInfoDao = new EmployeeInfoDaoImpl();
}
return employeeInfoDao;
}
}
-----------------------------------------------------------------------------------
------------------------
---------------------------------------------------EmployeeInfoDao
Impl------------------------------------------------------------------
package com.theVarunContextualHandsOn;

public class EmployeeInfoDaoImpl implements EmployeeInfoDao{


@Override
public void addEmployee(EmployeeInfo employeeInfo) {

@Override
public void updateEmployee(EmployeeInfo employeeInfo) {

@Override
public void deleteEmployee(int id) {

}
@Override
public void viewCustomerDetails(Customer customer) {

@Override
public void viewTransactions(TransactionInfo transactionInfo) {

}
}
-----------------------------------------------------------------------------------
-------------------
---------------------------------------------
TransactionInfo-----------------------------------------------------------
package com.theVarunContextualHandsOn;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class TransactionInfo {
@Id
int transaction_id;
int account_no;
int cust_id;
int amt_withdrawn;
int amt_deposit;

public TransactionInfo() {
}

public TransactionInfo(int transaction_id, int account_no, int cust_id, int


amt_withdrawn, int amt_deposit) {
this.transaction_id = transaction_id;
this.account_no = account_no;
this.cust_id = cust_id;
this.amt_withdrawn = amt_withdrawn;
this.amt_deposit = amt_deposit;
}

public int getTransaction_id() {


return transaction_id;
}

public void setTransaction_id(int transaction_id) {


this.transaction_id = transaction_id;
}

public int getAccount_no() {


return account_no;
}

public void setAccount_no(int account_no) {


this.account_no = account_no;
}

public int getCust_id() {


return cust_id;
}

public void setCust_id(int cust_id) {


this.cust_id = cust_id;
}

public int getAmt_withdrawn() {


return amt_withdrawn;
}

public void setAmt_withdrawn(int amt_withdrawn) {


this.amt_withdrawn = amt_withdrawn;
}

public int getAmt_deposit() {


return amt_deposit;
}

public void setAmt_deposit(int amt_deposit) {


this.amt_deposit = amt_deposit;
}

@Override
public String toString() {
return "TransactionInfo{" +
"transaction_id=" + transaction_id +
", account_no=" + account_no +
", cust_id=" + cust_id +
", amt_withdrawn=" + amt_withdrawn +
", amt_deposit=" + amt_deposit +
'}';
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy