@@ -0,0 +1,2500 @@
+package com.fatecpg.data;%0D%0A%0D%0Aimport br.com.fatecpg.helpers.ConnectionFactory;%0D%0Aimport java.sql.Connection;%0D%0Aimport java.sql.PreparedStatement;%0D%0Aimport java.sql.ResultSet;%0D%0Aimport java.sql.SQLException;%0D%0Aimport java.sql.Statement;%0D%0Aimport java.util.ArrayList;%0D%0A%0D%0Apublic class Alternativa %7B%0D%0A    private Integer _id;%0D%0A    private String _texto;%0D%0A    private boolean _correta;%0D%0A    private int _questaoId;%0D%0A    %0D%0A    // ------ CONSTRUTORES --------------%0D%0A    public Alternativa(String texto, boolean correta, int questionId) %7B%0D%0A        this._texto = texto;%0D%0A        this._correta = correta;%0D%0A        this._questaoId = questionId;%0D%0A    %7D%0D%0A%0D%0A    public Alternativa(Integer id, String texto, boolean correta, int questionId) %7B%0D%0A        this._id = id;%0D%0A        this._texto = texto;%0D%0A        this._correta = correta;%0D%0A        this._questaoId = questionId;%0D%0A    %7D%0D%0A%0D%0A    // ###### GETTERS E SETTERS #######%0D%0A    public int getId() %7B%0D%0A        return _id;%0D%0A    %7D%0D%0A%0D%0A    public String getTexto() %7B%0D%0A        return _texto;%0D%0A    %7D%0D%0A%0D%0A    public void setTexto(String texto) %7B%0D%0A        this._texto = texto;%0D%0A    %7D%0D%0A%0D%0A    public boolean isCorreta() %7B%0D%0A        return _correta;%0D%0A    %7D%0D%0A%0D%0A    public void setCorreta(boolean correta) %7B%0D%0A        this._correta = correta;%0D%0A    %7D%0D%0A%0D%0A    public int getQuestaoId() %7B%0D%0A        return _questaoId;%0D%0A    %7D%0D%0A%0D%0A    public void setQuestaoId(int _questaoId) %7B%0D%0A        this._questaoId = _questaoId;%0D%0A    %7D%0D%0A%0D%0A    //####### OPERA%C3%87%C3%95ES NO BANCO #######%0D%0A    // ------- CREATE ---------------------%0D%0A    // Insere o registro no banco de dados de acordo com os atributos do objeto%0D%0A    public boolean store() throws SQLException %7B%0D%0A        try (Connection connection = ConnectionFactory.getConnection()) %7B%0D%0A            try %7B%0D%0A                Statement statement = connection.createStatement();%0D%0A                String SQL = String.format(%22INSERT INTO ALTERNATIVA(TEXTO, CORRECT, QUESTAO_ID) VALUES('%25s', %25b, %25d)%22, this._texto, this._correta, this._questaoId);%0D%0A%0D%0A                statement.execute(SQL, Statement.RETURN_GENERATED_KEYS);%0D%0A%0D%0A                ResultSet rs = statement.getGeneratedKeys();%0D%0A%0D%0A                if (rs.next()) %7B%0D%0A                    this._id = rs.getInt(1);%0D%0A                %7D%0D%0A%0D%0A                rs.close();%0D%0A%0D%0A                if (this._id != null) %7B%0D%0A                    return true;%0D%0A                %7D%0D%0A            %7D catch (SQLException ex) %7B%0D%0A                throw ex;%0D%0A            %7D%0D%0A            connection.close();%0D%0A        %7D%0D%0A        return false;%0D%0A    %7D%0D%0A%7D

Implementa método para gravar Alternativa no BD