I have the following method to access data from two different tables, I am using the MVC pattern and my question is whether it is correct to return a ResultSet object in this method and if so, in what way can I access the data that contains the ResultSet from the view.
Since what is normally done is to create an ArrayList of the object that I return, but in this case, when returning data from two different tables, what I would do would be to return the data of two different object types, for example, for Table 1 create a class in the model called Table1 and for Table2 in the model create a class called Table2; then I would have to return objects of type Table1 and objects of type Table2; what comes to mind in the end is to return the resultset what I do not know is how to access each of the fields that contain the resultset from the view:
public ResultSet getProductos() throws Exception{
Connection miConexion=null;
Statement miStatement=null;
ResultSet miResultSet=null;
//----Establecer la conexion
miConexion=origenDatos.getConnection();
//-----Crear la sentencia sql
String consulta="SELECT T1.Col1, T1.Col2, T1.Col3, T2.Col7 FROM Tabla1 T1 INNER JOIN Tabla2 T2 ON T1.Col1 = T2.Col1";
miStatement=miConexion.createStatement();
//----Ejecutar la sentencia sql
miResultSet=miStatement.executeQuery(consulta);
//----Recorrer el ResultSet obtenido
return miResultSet;
}