Boa tarde pessALL sou iniciante em java e no curso q estou fazendo estamos fazend uso das Classes Abstratas
e estou tentando fazer a inserção de dados em um banco MYSQL e estou com o seguinte err :
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.Statement.checkForDml(Statement.java:412)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1364)
at abst.FrmUsuario.incluir(FrmUsuario.java:96)
at abst.FrmUsuario.actionPerformed(FrmUsuario.java:124)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
abaixo o metodo.
public boolean incluir() {
// TODO Auto-generated method stub
try{
String sql = “INSERT INTO USUARIO (nome,login,senha,situacao) VALUES(?,?,?,?)”;
ps = conexao.prepareStatement(sql);
ps.setString(1,editNome.getText());
ps.setString(2,editLogin.getText());
ps.setString(3,editSenha.getText());
ps.setInt(4,cboxSituacao.getSelectedIndex());
rs = ps.executeQuery();
comitar();
return true;
} catch (Exception exc) {
// TODO: handle exception
exc.printStackTrace();
return false;
}
}
Desde ja agradeço.