Porque essa consulta não funciona?

4 respostas
vitorkgb

Galera, tenho uma consulta em Access, no qual ela funciona perfeitamente no Access, mas em Java dá erro…

o erro que dá é “Parâmetros insuficientes. Eram esperados 4.”

sql = "SELECT DISTINCTROW [02 - Plataforma].Plataforma, [05 - Logística].Situação, [05 - Logística].Chapa, [04 - Pessoal].Nome, [04 - Pessoal].Função, [05 - Logística].Inicio, [05 - Logística].Termino, [05 - Logística].Ativo, [04 - Pessoal].Demitido FROM [04 - Pessoal] INNER JOIN (([02 - Plataforma] INNER JOIN [03 - Contrato x Plataforma] ON [02 - Plataforma].Plataforma = [03 - Contrato x Plataforma].Plataforma) INNER JOIN [05 - Logística] ON [03 - Contrato x Plataforma].Código = [05 - Logística].Locação) ON [04 - Pessoal].Chapa = [05 - Logística].Chapa GROUP BY [02 - Plataforma].Plataforma, [05 - Logística].Situação, [05 - Logística].Chapa, [04 - Pessoal].Nome, [04 - Pessoal].Função, [05 - Logística].Inicio, [05 - Logística].Termino, [05 - Logística].Ativo, [04 - Pessoal].Demitido, [03 - Contrato x Plataforma].[Off-Shore] HAVING ((([05 - Logística].Ativo)=True) AND (([04 - Pessoal].Demitido)=No) AND (([03 - Contrato x Plataforma].[Off-Shore])=False))";

4 Respostas

santanna106

você pode postar o código em que executa a Query através do jdbc?

vitorkgb
sql = "SELECT DISTINCTROW [02 - Plataforma].Plataforma, [05 - Logística].Situação, [05 - Logística].Chapa, [04 - Pessoal].Nome, [04 - Pessoal].Função, [05 - Logística].Inicio, [05 - Logística].Termino, [05 - Logística].Ativo, [04 - Pessoal].Demitido FROM [04 - Pessoal] INNER JOIN (([02 - Plataforma] INNER JOIN [03 - Contrato x Plataforma] ON [02 - Plataforma].Plataforma = [03 - Contrato x Plataforma].Plataforma) INNER JOIN [05 - Logística] ON [03 - Contrato x Plataforma].Código = [05 - Logística].Locação) ON [04 - Pessoal].Chapa = [05 - Logística].Chapa GROUP BY [02 - Plataforma].Plataforma, [05 - Logística].Situação, [05 - Logística].Chapa, [04 - Pessoal].Nome, [04 - Pessoal].Função, [05 - Logística].Inicio, [05 - Logística].Termino, [05 - Logística].Ativo, [04 - Pessoal].Demitido, [03 - Contrato x Plataforma].[Off-Shore] HAVING ((([05 - Logística].Ativo)=True) AND (([04 - Pessoal].Demitido)=No) AND (([03 - Contrato x Plataforma].[Off-Shore])=False))"; 
  
   statement = conexao.createStatement();  
   resultSet = statement.executeQuery(sql);  
    while(resultSet.next())  
    {  
    ....  
    }
vitorkgb

resolvido, parece q o Netbeams tem um bug ao ler tabelas ou nome de campos com acentos, pelo menos em access, fica ai a dica, quando gerei o jar, ele funcionou normalmente.

segue o link de onde consegui retirar a resposta

http://javafree.uol.com.br/topic-874586-Trocando-acentos-por.html

S

voce es pescador ou programador???

se fores pescador continua a usar nomes de tabelas, variavieis , etc com acentos,
senão pesquisa e veras que isso é uma pessima pessima pratica.

Criado 17 de dezembro de 2010
Ultima resposta 17 de dez. de 2010
Respostas 4
Participantes 3