ExecuteSQL method definition error [closed]

1

When creating the execute method it generates error at this point rs = stm.executeQuery (sql) what can i do

public void excutaSQL(String sql){
        try {
            stm=(Statement) conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);

            rs = stm.executeQuery(sql);// o erro está neste linha 
        } catch (SQLException ex) {
            Logger.getLogger(Conection.class.getName()).log(Level.SEVERE, null, ex);
        }

     }
  

error: can not find symbol
              rs = stm.executeQuery (sql);
    symbol: method executeQuery (String)
    location: variable stm of type Statement
  1 error

import java.beans.Statement;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
    
asked by anonymous 01.02.2017 / 14:10

1 answer

5

You are importing the wrong Statement class. Change the import of class Statement to the following:

import java.sql.Statement;

Or just remove the line below, you're already doing import for all classes (with import java.sql.* ):

import java.beans.Statement;

Class documentation java.sql.Statement

    
01.02.2017 / 14:38