Código:
La clase a la que pertenece es esta:public ResultSet ejecutarSQLEstatico(String query){ ResultSet rs = null; try{ rs = consulta.executeQuery(query); } catch(SQLException ex){ rs = null; } return rs; }
Código:
package Datos; import java.sql.*; public class BaseDatos { private Statement consulta = null; private Connection conexion = null; public BaseDatos(){ try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch(InstantiationException ex){ System.out.println(ex.getMessage()); } catch(IllegalAccessException ex){ System.out.println(ex.getMessage()); } catch(ClassNotFoundException ex){ System.out.println(ex.getMessage()); } } public void abrir(){ try{ conexion = DriverManager.getConnection("jdbc:mysql://localhost/cambio", "root", "bruni_24"); consulta = conexion.createStatement(ResultSet.CONCUR_UPDATABLE, ResultSet.TYPE_SCROLL_SENSITIVE); } catch(SQLException ex){ System.out.println(ex.getMessage()); } } public void cerrar(){ try{ consulta.close(); conexion.close(); } catch(SQLException ex){ System.out.println(ex.getMessage()); } } public int ejecutarSQLDinamico(String query){ int afectados = 0; try{ afectados = consulta.executeUpdate(query); } catch(SQLException ex){ System.out.println(ex.getMessage()); afectados = 0; } return afectados; } public ResultSet ejecutarSQLEstatico(String query){ ResultSet rs = null; try{ rs = consulta.executeQuery(query); } catch(SQLException ex){ rs = null; } return rs; } }