@Component@Repository("customerDAO")publicclassCustomerDAO{@AutowiredprivateJdbcTemplatejdbcTemplate;publicvoidcreateTable(StringtableName){jdbcTemplate.execute("DROP TABLE IF EXISTS "+tableName);jdbcTemplate.execute("CREATE TABLE "+tableName+"("+"nickname VARCHAR(45) NOT NULL ,"+"dateOfBirth DATETIME NOT NULL,"+"balance DOUBLE NOT NULL, "+"PRIMARY KEY(nickname)"+");");}publicvoidaddCustomer(Customercustomer,StringtableName)throwsDuplicateCustomerException{StringSQL="insert into "+tableName+"(nickname, dateOfBirth, balance) values (?, ?, ?)";try{jdbcTemplate.update(SQL,newObject[]{customer.getNickname(),customer.getDateOfBirth(),customer.getBalance()});}catch(DuplicateKeyExceptionexception){thrownewDuplicateCustomerException("Customer with nickname "+customer.getNickname()+" has already existed");}}publicCustomergetCustomer(Stringnickname,StringtableName)throwsCustomerNotFoundException{StringSQL="select * from "+tableName+" where nickname = ?";Customercustomer;try{customer=jdbcTemplate.queryForObject(SQL,newObject[]{nickname},newCustomerMapper());}catch(EmptyResultDataAccessExceptionexception){thrownewCustomerNotFoundException("Customer with nickname "+nickname+" is not found");}returncustomer;}publicDoublegetBalance(Stringnickname,StringtableName){StringSQL="select balance from "+tableName+" where nickname = ?";doublebalance=jdbcTemplate.queryForObject(SQL,newObject[]{nickname},Double.class);returnbalance;}publicvoidwithdrawBalance(Stringnickname,doublebalanceToWithdraw,StringtableName)throwsBalanceOverdrawException{doublebalanceBefore=getBalance(nickname,tableName);doublebalanceAfter=balanceBefore-balanceToWithdraw;if(balanceAfter<0){thrownewBalanceOverdrawException("You have only "+balanceBefore+"$. You can not withdraw "+balanceToWithdraw+"$");}StringSQL="update "+tableName+" set balance = ? where nickname = ?";jdbcTemplate.update(SQL,newObject[]{balanceAfter,nickname});}publicvoiddeposit(Stringnickname,doublebalanceToDeposit,StringtableName){doublebalanceBefore=getBalance(nickname,tableName);doublebalanceAfter=balanceBefore+balanceToDeposit;StringSQL="update "+tableName+" set balance = ? where nickname = ?";jdbcTemplate.update(SQL,newObject[]{balanceAfter,nickname});}}