Commit 4c90b7d7 by Mihailo Sebek

insertZahtev procedura

parent c4067885
......@@ -9,8 +9,7 @@ import java.sql.*;
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Zahtev
{
public class Zahtev {
int terminId;
int korisnikId;
int oglasId;
......@@ -18,3 +17,4 @@ public class Zahtev
String vreme;
StanjeZahteva status;
}
......@@ -4,6 +4,7 @@ import com.example.SkuciSe.model.zahtev.Zahtev;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.sql.CallableStatement;
import java.sql.SQLException;
@Component
......@@ -18,9 +19,17 @@ public class ZahtevRepository {
noviZahtev.setVreme( vreme);
System.out.println( noviZahtev.toString());
String sql = "insert into zahtev( oglasid, korisnikid, datum, vreme, stanje) values ("+noviZahtev.getOglasId()+","+noviZahtev.getKorisnikId()+",'"+noviZahtev.getDatum()+"','"+noviZahtev.getDatum()+"','"+noviZahtev.getStatus()+"')";
// String sql = "insert into zahtev( oglasid, korisnikid, datum, vreme, stanje) values ("+noviZahtev.getOglasId()+","+noviZahtev.getKorisnikId()+",'"+noviZahtev.getDatum()+"','"+noviZahtev.getDatum()+"','"+noviZahtev.getStatus()+"')";
String sql="{call insertZahtev(?,?,?,?,?)}";
CallableStatement stmt=null;
try {
dataBase.statement.executeUpdate( sql);
stmt=dataBase.connection.prepareCall(sql);
stmt.setInt(1,noviZahtev.getKorisnikId());
stmt.setInt(2,noviZahtev.getOglasId());
stmt.setString(3,noviZahtev.getDatum());
stmt.setString(4,noviZahtev.getVreme());
stmt.setString(5,noviZahtev.getStatus().toString());
stmt.executeUpdate();
} catch (SQLException e) {
throw new RuntimeException(e);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment