Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.spec.service;
- import com.spec.DBUtil;
- import com.spec.model.UserAccount;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import java.util.List;
- public class UserAccountService implements IUserAccountService{
- @Override
- public int createAccount(UserAccount user) throws Exception {
- return 0;
- }
- @Override
- public boolean setAccount(UserAccount user) throws Exception {
- return true;
- }
- @Override
- public void removeAccount(String userName) throws Exception {
- // -- DELETE
- final String sql = "DELETE FROM accounts WHERE username=?";
- try(Connection c = DBUtil.getConn();
- PreparedStatement ps = c.prepareStatement(sql);){
- // установка параметра userName
- ps.setString(1, userName);
- // выполнение запроса
- int res = ps.executeUpdate();
- System.out.println("removeAccount.res=" + res);
- }catch(SQLException ex){
- ex.printStackTrace();
- throw new Exception("error while removeAccount", ex);
- }
- }
- @Override
- public UserAccount getUserAccount(String userName) {
- return null;
- }
- @Override
- public List<UserAccount> getAll() {
- return null;
- }
- @Override
- public List<UserAccount> findAccounts(Object filter) {
- return null;
- }
- //
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement