[RESOLVIDO] MySQLSyntaxErrorException ao realizar select

4 respostas Resolvido
javamysql
cleitonoliveira

Pessoal, será que alguém poderia me ajudar com o erro abaixo?

Erro!!
com.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 ‘tbl_cliente’ at line 1

mysql!!
public boolean relatorioClientesDAO() {

try {
        this.conectar();
        this.executarSQL(
                "SELECT "
                + "     tbl_cliente.pk_id_cliente AS tbl_cliente_pk_id_cliente,"
                + "     tbl_cliente.cli_nome AS tbl_cliente_cli_nome,"
                + "     tbl_cliente.cli_endereco AS tbl_cliente_cli_endereco,"
                + "     tbl_cliente.cli_bairro AS tbl_cliente_cli_bairro,"
                + "     tbl_cliente.cli_cidade AS tbl_cliente_cli_cidade,"
                + "     tbl_cliente.cli_uf AS tbl_cliente_cli_uf,"
                + "     tbl_cliente.cli_cep AS tbl_cliente_cli_cep,"
                + "     tbl_cliente.cli_telefone AS tbl_cliente_cli_telefone,"
                + "     tbl_cliente.cli_veiculo AS tbl_cliente_cli_veiculo"
                + "FROM "
                + "      tbl_cliente"
        );
        JRResultSetDataSource jrRs = new JRResultSetDataSource(getResultSet());
        InputStream caminhoRelatorio = this.getClass().getClassLoader().getResourceAsStream("ireport/cliente.jasper");
        JasperPrint jasperPrint = JasperFillManager.fillReport(caminhoRelatorio, new HashMap(), jrRs);
        JasperExportManager.exportReportToPdfFile(jasperPrint, "relatorios/cliente.pdf");
        File file = new File("relatorios/cliente.pdf");
        try {
            Desktop.getDesktop().open(file);
        } catch (Exception e) {
            JOptionPane.showConfirmDialog(null, e);
        }
        file.deleteOnExit();
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    } finally {
        this.fecharConexao();
    }
}

Tenho outros 3 relatorios que funcionam perfeitamente e o codigo é o mesmo, apenas este não quer funcionar.

4 Respostas

TerraSkilll

Coloque espaços antes do FROM, depois da aspa, e teste.

+ " FROM "

Abraço.

S
Solucao aceita

Cleiton não sei se pode ser isso, mas acho que o seu FROM esta ficando colado com veiculo, de um espaco em " tbl_cliente.cli_veiculo AS tbl_cliente_cli_veiculo "

Espero ter ajudado

ardenghe

" FROM "

cleitonoliveira

Obrigado pessoal, como sempre o bendito espaço kkkk faltou um espaço mesmo agradeço a todos.

Criado 16 de julho de 2018
Ultima resposta 16 de jul. de 2018
Respostas 4
Participantes 4