0
Staff I’m doing a job for the college I got on the report part and I created the report as the image shows
However I could only make the name field work in a second java class I created using the following code
public class rela_clientes_nome {
conexaoBD conn = new conexaoBD();
public void rela_clientes(String nome) {
try {
conn.conexao();
conn.executaSql("select * from clientes where nome like '%"+nome+"%'");
JRResultSetDataSource relatResul = new JRResultSetDataSource(conn.rs);
JasperPrint jpPrint = JasperFillManager.fillReport("src/rela_ireport/clientes.jasper", new HashMap(), relatResul);
JasperViewer jv = new JasperViewer(jpPrint, false);
jv.setVisible(true);
jv.toFront();
} catch (JRException ex) {
Logger.getLogger(rela_clientes_nome.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Good that way I called on the button print the report created with IREPORT and this puchando only by the NAME FILTER as shows the code:
private void jButtonImprimirActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
rela_clientes relatorio = new rela_clientes();
relatorio.rela_clientes(jTextFieldNome.getText());
}
Good would like to know how to fix the two filters NAME and CPF working together?
Read about injection of SQL.
– Victor Stafusa
What is
conn
? Can you edit the question and put the code of this class? I recommend you take a look in that question and in your answers as well.– Victor Stafusa
Conn is the instance with the connected database();
– henrique missio