5
If I run a query in the database returns result, however, when running java code, assigning the result to a Resultset, the same appears to be empty. You can help me?
PreparedStatement ps = conectar.con.prepareStatement("select colaborador.codigo as 'colabcod', nome,"
+ " emprestimo.codigo as 'emprescod', idcolaborador, dataempres from emprestimo, colaborador where "
+ "idcolaborador = colaborador.codigo and dataEmpres between ? and ?");
ps.setString(1, "'" + datainicial + "'");
ps.setString(2, "'" + datafinal + "'");
ResultSet rs = ps.executeQuery();
if (!rs.next()) {
JOptionPane.showMessageDialog(null, "Não há resultados para essa pesquisa");
}else{
while (rs.next()) {
model.addRow(new String[]{rs.getString("emprescod"), rs.getString("nome"),
rs.getString("dataempres"), "<Não Definido>"});
}
}
That’s correct, now I’ve removed the apostrophes of both setString() and SQL command and it worked perfectly. Thank you!
– Marco Aurélio Souza
@Marcoauréliosouza If this answer has solved your problem, click the green mark to mark the question as solved and to mark that this answer served to solve it.
– Victor Stafusa
All right, thank you!
– Marco Aurélio Souza