Já testei a consulta no MYSQL e funciona direitinho só
que quando coloco no meu código java não funciona de jeito nenhum.
public ArrayList<Emprestimo> pesquisa(String nome) {
ArrayList<Emprestimo> listaEmprestimo = new ArrayList<Emprestimo>();
try {
sql = "SELECT e.idemprestimo, c.nome, f.titulo, e.dataemp"
+ "from emprestimo e"
+ "INNER JOIN cliente c ON c.idcliente = e.idcliente"
+ "INNER JOIN filme f ON f.idfilme = e.idfilme"
+ "where c.nome like '%" +nome+ "%' ";
con = new conexao();
con.getConnection();
pstmt = con.connection.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) {
emprestimo = new Emprestimo();
emprestimo.setIdemprestimo(rs.getInt("idemprestimo"));
emprestimo.setNome(rs.getString("nome"));
emprestimo.setTitulo(rs.getString("titulo"));
emprestimo.setDataEmprestimo(rs.getDate("dataemp"));
listaEmprestimo.add(emprestimo);
}
} catch (SQLException erro) {
System.out.println("erro" + erro);
}
return listaEmprestimo;
}
erro que aparece :
errocom.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘eINNER JOIN cliente c ON c.idcliente = e.idclienteINNER JOIN filme f ON f.idfilm’ at line 1