Professional Documents
Culture Documents
package com.customer.controller;
import com.customer.dao.AccountDAO;
import com.customer.entities.Account;
import java.util.*;
public AccountController()
{this.accountDAO = new AccountDAO();}
CUSTOMER CONTROLLER
package com.customer.controller;
import com.customer.dao.CustomerDAO;
import com.customer.entities.Customer;
import java.util.*;
public CustomerController()
{this.customerDAO = new CustomerDAO();}
LOGIN CONTROLLER
package com.customer.controller;
import com.customer.dao.*;
import com.customer.entities.*;
import com.customer.helper.Helper;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
public LoginController()
{this.loginDAO = new LoginDAO();}
return login;
}
}
ACCOUNT DAO
package com.customer.dao;
import com.customer.entities.Account;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import com.customer.helper.Helper;
Helper.closeConnectionPreparedStatement();
return flag;
}
return account;
}
return customer.get(0);
}
return customer;
}*/
}
CUSTOMER DAO
package com.customer.dao;
import com.customer.entities.Customer;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import com.customer.helper.Helper;
Helper.closeConnectionPreparedStatement();
return flag;
}
return customer;
}
public boolean updateCustomer(Customer customer,int id)
{
boolean flag = false;
String query = "update Customer set ssnid
= ?,custid=?,status=?,mess=?,lastupdated=? where ssnid = ? ";
PreparedStatement preparedStatement =
Helper.getConnectionPreparedStatement(query);
try{
preparedStatement.setInt(1,customer.getssnid());
preparedStatement.setInt(2,customer.getcustomerid());
preparedStatement.setString(3,customer.getstatus());
preparedStatement.setString(4,customer.getmessage());
preparedStatement.setString(5,customer.getlastUpdated());
preparedStatement.setInt(6,id);
return flag;
}*/
return customer.get(0);
}
return customer;
}*/
}
LOGIN DAO
package com.customer.dao;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import com.customer.entities.*;
import com.customer.helper.Helper;
ACCOUNT
package com.customer.entities;
public Account()
{
}
public Account(int custid, int accid, String acctype, String status, String
mess, String lastupdated)
{
this.custid = custid;
this.accid = accid;
this.acctype = acctype;
this.status = status;
this.mess = mess;
this.lastupdated = lastupdated;
@Override
public String toString() {
CUSTOMER
package com.customer.entities;
public Customer()
{
this.ssnID = ssnID;
this.customerID = customerID;
this.status = status;
this.message = message;
this.lastUpdated = lastUpdated;
@Override
public String toString() {
return "Customer [SSNID = " + ssnID + ", CustomerID = " + customerID +
", Status = " + status + ", Message = " + message
+ ", Last Updated = " + lastUpdated + "]";
}
LOGIN
package com.customer.entities;
public Login()
{
this.username = username;
this.password = password;
@Override
public String toString() {
BASE QUERY
package com.customer.helper;
import java.sql.Statement;
Helper.closeConnectionStatement();
}
Helper.closeConnectionStatement();
}
Helper.closeConnectionStatement();
}
}
HELPER
package com.customer.helper;
import java.sql.*;
Helper.connection =
DriverManager.getConnection("jdbc:derby:demoDB;create=true");
Helper.statement = Helper.connection.createStatement();
return Helper.statement;
}
catch(ClassNotFoundException ex){
ex.printStackTrace();
return null;
}
catch(SQLException ex){
ex.printStackTrace();
return null; }
}
Helper.connection =
DriverManager.getConnection("jdbc:derby:demoDB;create=true");
Helper.preparedStatement =
Helper.connection.prepareStatement(sql);
return Helper.preparedStatement;
}
catch(ClassNotFoundException ex){
ex.printStackTrace();
return null;
}
catch(SQLException ex)
{ ex.printStackTrace();
return null;}
}
// Create Closing Function