I'm doing a DAO and I need to insert in two different tables in the BDs. I know I can do it with Autocommit
. But the idea is to go through the different inserts as a parameter and use the Autocommit
in the method.
The code simplifies it by removing the try and catch.
The method you program is this:
public void reserva(String query) {
Reserva rsv = new Reserva();
dateString = sdfr.format(rsv.getFechaLlegada());
PreparedStatement busquedaStmt = null;
String busquedaString = query;
busquedaStmt =
con.getConexion().prepareStatement(busquedaString);
busquedaStmt.setString(1, dateString);
ResultSet rs = busquedaStmt.executeQuery();
}
And I would use it in servlet
like this:
ReservaDAOImp reserva = new ReservaDAOImp();
reserva.reserva("INSERT INTO T_cliente (cliente) values (?)")
reserva.reserva("INSERT INTO T_reserva (fechaLlegada) values
(?)");