/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package util.dao;

import entities.Knjiga;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author jelic
 */
public class KnjigaDAO {
    public void dodajKnjigu(Knjiga k){
        Connection conn = util.DB.getInstance().getConnection();
        try(PreparedStatement st = conn.prepareStatement("insert into knjige (pisac, naziv, brstr) values (?,?,?)")){
            st.setString(1, k.getPisac());
            st.setString(2, k.getNaziv());
            st.setInt(3, k.getBrstr());
            
            st.executeUpdate();
        } catch (SQLException ex) {
            Logger.getLogger(KnjigaDAO.class.getName()).log(Level.SEVERE, null, ex);
        } finally{
            util.DB.getInstance().putConnection(conn);
        }
                
    }
}
