public void save(){
        if(this.getId() != null){
            String q = "SELECT id, " +
                    "first_name," +
                    "middle_name," +
                    "last_name," +
                    "position " +
                    "FROM workers " +
                    "WHERE id = ? " +
                    "LIMIT 1";
            try {
                PreparedStatement statement = Worker.connection.prepareStatement(q,
                        ResultSet.TYPE_FORWARD_ONLY,
                        ResultSet.CONCUR_UPDATABLE);
                statement.setInt(1, this.getId());
                ResultSet resultSet = statement.executeQuery();
                if(resultSet.next()){
                    resultSet.updateString("first_name", this.getFirstName());
                    resultSet.updateString("last_name", this.getLastName());
                    resultSet.updateString("middle_name", this.getMiddleName());
                    resultSet.updateInt("position", this.getSpeciality().getId());
                    resultSet.updateRow();
                }

            } catch (SQLException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }
        } else {
            String q = "INSERT INTO workers " +
                    "(first_name," +
                    "last_name," +
                    "middle_name," +
                    "position) " +
                    "VALUES " +
                    "(?,?,?,?)";
            try {
                PreparedStatement statement = Worker.connection.prepareStatement(q, Statement.RETURN_GENERATED_KEYS);
                statement.setString(1, this.getFirstName());
                statement.setString(2, this.getLastName());
                statement.setString(3, this.getMiddleName());
                statement.setInt(4, this.getSpeciality().getId());
                statement.executeUpdate();
                ResultSet resultSet = statement.getGeneratedKeys();
                if(resultSet.next()){
                    this.setId(resultSet.getInt(1));
                }
            } catch (SQLException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }
        }
    }