@@ -0,0 +1,3159 @@
+package com.javarush.task.task21.task2111;%0A%0Aimport java.sql.Connection;%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0Aimport java.sql.Statement;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0A/* %0A%D0%9E%D1%81%D0%B2%D0%BE%D0%B1%D0%BE%D0%B6%D0%B4%D0%B0%D0%B5%D0%BC %D1%80%D0%B5%D1%81%D1%83%D1%80%D1%81%D1%8B%0A*/%0Apublic class Solution %7B%0A    private Connection connection;%0A%0A    public Solution(Connection connection) %7B%0A        this.connection = connection;%0A    %7D%0A%0A    public List%3CUser%3E getUsers() %7B%0A        String query = %22select ID, DISPLAYED_NAME, LEVEL, LESSON from USER%22;%0A%0A        List%3CUser%3E result = new LinkedList();%0A%0A//        Statement stmt = null;%0A//        ResultSet rs = null;%0A//%0A//        try %7B%0A//            stmt = connection.createStatement();%0A//            rs = stmt.executeQuery(query);%0A//            while (rs.next()) %7B%0A//                int id = rs.getInt(%22ID%22);%0A//                String name = rs.getString(%22DISPLAYED_NAME%22);%0A//                int level = rs.getInt(%22LEVEL%22);%0A//                int lesson = rs.getInt(%22LESSON%22);%0A//%0A//                result.add(new User(id, name, level, lesson));%0A//            %7D%0A//        %7D catch (SQLException e) %7B%0A//            e.printStackTrace();%0A//            result = null;%0A//        %7D finally %7B%0A//            if(stmt != null) %7B%0A//                try %7B%0A//                    stmt.close();%0A//                %7D catch (SQLException e) %7B%0A//                    e.printStackTrace();%0A//                %7D%0A//            %7D%0A//            if(rs != null) %7B%0A//                try %7B%0A//                    rs.close();%0A//                %7D catch (SQLException e) %7B%0A//                    e.printStackTrace();%0A//                %7D%0A//            %7D%0A//        %7D%0A//        return result;%0A//    %7D%0A%0A        try %7B%0A            try (%0A                    Statement stmt = connection.createStatement();%0A                    ResultSet rs = stmt.executeQuery(query);%0A            ) %7B%0A                while (rs.next()) %7B%0A                    int id = rs.getInt(%22ID%22);%0A                    String name = rs.getString(%22DISPLAYED_NAME%22);%0A                    int level = rs.getInt(%22LEVEL%22);%0A                    int lesson = rs.getInt(%22LESSON%22);%0A%0A                    result.add(new User(id, name, level, lesson));%0A                %7D%0A            %7D%0A        %7D catch (SQLException e) %7B%0A            e.printStackTrace();%0A            result = null;%0A        %7D%0A%0A        return result;%0A    %7D%0A%0A    @Override%0A    protected void finalize() throws Throwable %7B%0A        super.finalize();%0A        if (connection != null)%0A            connection.close();%0A    %7D%0A%0A    public static class User %7B%0A        private int id;%0A        private String name;%0A        private int level;%0A        private int lesson;%0A%0A        public User(int id, String name, int level, int lesson) %7B%0A            this.id = id;%0A            this.name = name;%0A            this.level = level;%0A            this.lesson = lesson;%0A        %7D%0A%0A        @Override%0A        public String toString() %7B%0A            return %22User%7B%22 +%0A                    %22id=%22 + id +%0A                    %22, name='%22 + name + '%5C'' +%0A                    %22, level=%22 + level +%0A                    %22, lesson=%22 + lesson +%0A                    '%7D';%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A    %7D%0A%7D%0A

Task --> 2111