I am trying to develop a small example of what I understood about object-oriented programming with JAVA, but I have a question, I have two objects: PROCESS AND REQUEST the procedure has a relation with request, I have a method in which it is called addTrite and another one that is called addRequest, in each one I use a prepareStatement. What I need is that when adding a new procedure a new request is added. I do not know how to treat the two transactions
I create an instance of the procedure:
Tramite nuevoTramite = newTramite();
nuevoTramite.agregarTramite();
and within the method addTramite I create an instance of the request so that the record is inserted in the database
class Tramite(){
public boolean agregarTramite(){
..
..
PreparedStatement agregarNuevaSolicitud =
conection.prepareStatement(nuevaSolicitudQuery);
agregarTramite.setTimestamp(1, Fecha.fechaActual());
..
..
Solicitud nuevaSolicitud = new Solicitud();
nuevaSolicitud.agregarNuevaSolicitud();
conection.commit();
stmt.close();
conection.close();
..
..
}
but I think this is wrong, how can I use a commit for transactions that are in different classes, is that possible? I hope you can help me.
Thank you very much