Ignore:
Timestamp:
02/03/24 18:08:44 (9 months ago)
Author:
Blazho <aleksandar.blazhevski@…>
Branches:
master
Children:
cab1b7d
Parents:
aea04dd
Message:

Posetitelot komentira i dava ocena za recept(https://develop.finki.ukim.mk/projects/cbdb/wiki/useCase11)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/cookbook/repository/KomentariRepository.java

    raea04dd rd4d8fb9  
    66import org.springframework.stereotype.Repository;
    77
    8 import java.sql.Connection;
    9 import java.sql.PreparedStatement;
    10 import java.sql.ResultSet;
    11 import java.sql.SQLException;
     8import java.sql.*;
    129import java.time.LocalDateTime;
    1310import java.util.ArrayList;
     
    4845        return komentari;
    4946    }
     47
     48    public void save(Komentar komentar) throws SQLException {
     49        Connection connection = DB.getConnection();
     50
     51        String query = "insert into komentari (kom_data, telefon, rec_id, ocena, text) values \n" +
     52                "        (?, ?, ?, ?, ?);";
     53
     54        PreparedStatement prepStm = connection.prepareStatement(query);
     55        prepStm.setObject(1, komentar.getKomData());
     56        prepStm.setString(2, komentar.getTelefon());
     57        prepStm.setLong(3, komentar.getRecId());
     58        prepStm.setInt(4, komentar.getOcena());
     59        prepStm.setString(5, komentar.getText());
     60
     61        prepStm.executeUpdate();
     62
     63        prepStm.close();
     64        DB.closeConnection();
     65    }
    5066}
Note: See TracChangeset for help on using the changeset viewer.