Commit 4c90b7d7 by Mihailo Sebek

insertZahtev procedura

parent c4067885
...@@ -9,8 +9,7 @@ import java.sql.*; ...@@ -9,8 +9,7 @@ import java.sql.*;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ToString @ToString
public class Zahtev public class Zahtev {
{
int terminId; int terminId;
int korisnikId; int korisnikId;
int oglasId; int oglasId;
...@@ -18,3 +17,4 @@ public class Zahtev ...@@ -18,3 +17,4 @@ public class Zahtev
String vreme; String vreme;
StanjeZahteva status; StanjeZahteva status;
} }
...@@ -4,6 +4,7 @@ import com.example.SkuciSe.model.zahtev.Zahtev; ...@@ -4,6 +4,7 @@ import com.example.SkuciSe.model.zahtev.Zahtev;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.sql.CallableStatement;
import java.sql.SQLException; import java.sql.SQLException;
@Component @Component
...@@ -18,9 +19,17 @@ public class ZahtevRepository { ...@@ -18,9 +19,17 @@ public class ZahtevRepository {
noviZahtev.setVreme( vreme); noviZahtev.setVreme( vreme);
System.out.println( noviZahtev.toString()); 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 { 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) { } catch (SQLException e) {
throw new RuntimeException(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