Erro "Can not issue data manipulation statements with executeQuery"

1 resposta
Lindeberg73
public void executUpdate( String update )
      throws SQLException, IllegalStateException
   {
      // assegura que o banco de dados conexão está disponível
      if ( !connectedToDatabase )
         throw new IllegalStateException( "Not Connected to Database" );

        statement.executeQuery( update );

   } // fim do método setQuery

   // fecha Statement e Connection
   public void disconnectFromDatabase()
   {
      if ( !connectedToDatabase )
         return;

      // fecha Statement e Connection
      try
      {
         statement.close();
         connection.close();
      } // fim do try
      catch ( SQLException sqlException )
      {
         sqlException.printStackTrace();
      } // fim do catch
      finally  // atualiza status de conexão de banco de dados
      {
         connectedToDatabase = false;
      } // fim do finally
   } // fim do método disconnectFromDatabase

tá dando o seguinte erro

java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.StatementImpl.checkForDml(StatementImpl.java:412)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1297)
at ResultSetTableModel.executUpdate(ResultSetTableModel.java:179)

1 Resposta

Lindeberg73
if(e.getSource()== botaoAdicionar){

                    String dados = "insert into pessoa(Titulo,Nome,Curso) values (" + "'" + queryTitulo + "' , " + "'" + queryNome + "' , " + "'" + queryCurso + "');";
                    textFieldNome.setText("");
                try {
                    TableModel.executUpdate(dados);
                } catch (SQLException ex) {
                    Logger.getLogger(Telap.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IllegalStateException ex) {
                    Logger.getLogger(Telap.class.getName()).log(Level.SEVERE, null, ex);
                }
                        }

Aqui é onde eu faço minha isenção

Criado 26 de maio de 2010
Ultima resposta 26 de mai. de 2010
Respostas 1
Participantes 1