String op= (String) Lista.getSelectedItem();
ResultSet rs = st.executeQuery("select * from Veiculo where Modelo '=" + op + "and where Locado is Null order by Modelo");
java.sql.SQLException: 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 ''=nulland where Locado is Null order by Modelo' at line 1
ResultSetrs=st.executeQuery("select * from Veiculo where Modelo '="+op+" and where Locado is Null order by Modelo");
Mas o certo MESMO seria usar PreparedStatements:
TheKill
[quote=LIPE]Falta um espaço depois de “op”.
O certo ficaria:
ResultSetrs=st.executeQuery("select * from Veiculo where Modelo '="+op+" and where Locado is Null order by Modelo");
Mas o certo MESMO seria usar PreparedStatements:
Amigo testei seu Code mas tbm nao funcionou, gerou o seguinte erro.
java.sql.SQLException: 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 ''=null and where Locado is Null order by Modelo' at line 1
Obrigado, aguardo resposta
TheKill
PreparedStatement pstmt = con.prepareStatement("select * from Veiculo where Modelo = ? and where Locado is Null order by Modelo");
pstmt.setString( 1, op );
ResultSet rs = pstmt.executeQuery();
Tentei esse codigo tbm, mas tbm gerou erro de Sintaxe.
Peço Ajuda é importante preciso terminar esse projeto.