Olá a todos, estou tentando fazer um select mas está retornando o erro:
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 'select ‘TbCompra_idTbCompra’ from TbInfoCompra where ‘dataCompra’=‘260313’ and ‘’ at line 1
Bom… o código é esse:
String sqlSelectInfoCompra = "use sistema_vendas;select 'TbCompra_idTbCompra' from TbInfoCompra where 'dataCompra'="
+ " ' " +info.getDataCompra() + " ' " +" and 'TbItem_idTbItem'=" +item.getIdItem()+
" and 'TbCompra_idTbCompra'=" + info2.getIdTbCompra() + ";" ;
System.out.println(sqlSelectInfoCompra);
java.sql.Statement stmSelectInfoCompra = conn.createStatement();
ResultSet rsSelectInfoCompra = stmSelectInfoCompra.executeQuery(sqlSelectInfoCompra);
info.setIdTbCompra(rsSelectInfoCompra.getInt(1));
Eu dei um print na string que está sendo passada para executeQuery, e a testei na linha de comando e no workbench e funcionou sem problema,
ai fiquei perdido, como estou começando agora com mysql e jdbc, resolvi pedir ajuda qui no fórum, se alguém puder ajudar ficarei muito grato.
Estou usando MySQL 5 e linux(Ubuntu).
Desde já obrigado a todos.