Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.0 kB
2
Indexable
Never
    public int getNumberUserDb(){
        Connection connection = MySqlRead_Data_DataBase.getMySQLConnection();
        Statement statement;
        List<Integer> totalUsers = new ArrayList<Integer>();
        List<String> listUser = new ArrayList<>();
        try {
            statement = connection.createStatement();
            String sql = "SELECT * FROM `bank`";
            ResultSet resultSet = statement.executeQuery(sql);
            while (resultSet.next()){
                int userID = resultSet.getInt(1);
                String user = resultSet.getString(1);
                totalUsers.add(userID);
                listUser.add(user);
            }
        }catch (SQLException e){
            e.printStackTrace();
        }finally {
            try {
                if(connection != null){
                    connection.close();
                }

            }catch (SQLException e){
                e.printStackTrace();
            }
        }
        return listUser.size() ;
    }