- Timestamp:
- 02/03/24 18:08:44 (9 months ago)
- Branches:
- master
- Children:
- cab1b7d
- Parents:
- aea04dd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/cookbook/repository/KomentariRepository.java
raea04dd rd4d8fb9 6 6 import org.springframework.stereotype.Repository; 7 7 8 import java.sql.Connection; 9 import java.sql.PreparedStatement; 10 import java.sql.ResultSet; 11 import java.sql.SQLException; 8 import java.sql.*; 12 9 import java.time.LocalDateTime; 13 10 import java.util.ArrayList; … … 48 45 return komentari; 49 46 } 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 } 50 66 }
Note:
See TracChangeset
for help on using the changeset viewer.