Advertisement
sergAccount

Untitled

Sep 27th, 2020
986
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.72 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.spec.service;
  7.  
  8. import com.spec.DBUtil;
  9. import com.spec.model.UserAccount;
  10. import java.sql.Connection;
  11. import java.sql.PreparedStatement;
  12. import java.sql.SQLException;
  13. import java.util.List;
  14.  
  15. public class UserAccountService implements IUserAccountService{
  16.  
  17.     @Override
  18.     public int createAccount(UserAccount user) throws Exception {
  19.        
  20.         return 0;
  21.     }
  22.  
  23.     @Override
  24.     public boolean setAccount(UserAccount user) throws Exception {
  25.        
  26.         return true;
  27.     }
  28.  
  29.     @Override
  30.     public void removeAccount(String userName) throws Exception {
  31.         // -- DELETE        
  32.         final String sql = "DELETE FROM accounts WHERE username=?";
  33.         try(Connection c = DBUtil.getConn();
  34.                 PreparedStatement ps = c.prepareStatement(sql);){              
  35.             // установка параметра userName
  36.             ps.setString(1, userName);
  37.             // выполнение запроса
  38.             int res = ps.executeUpdate();            
  39.             System.out.println("removeAccount.res=" + res);
  40.         }catch(SQLException ex){
  41.             ex.printStackTrace();
  42.             throw new Exception("error while removeAccount", ex);
  43.         }
  44.     }
  45.  
  46.     @Override
  47.     public UserAccount getUserAccount(String userName) {
  48.         return null;
  49.     }
  50.  
  51.     @Override
  52.     public List<UserAccount> getAll() {
  53.         return null;
  54.     }
  55.  
  56.     @Override
  57.     public List<UserAccount> findAccounts(Object filter) {
  58.         return null;
  59.     }    
  60.     //
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement