public int inserir(Livro l){
        Connection conn = null;
        PreparedStatement pstm = null;
        int retorno = -1;
        try{
            conn = ConnectionFactory.getConnection();
            pstm = conn.prepareStatement(INSERT, Statement.RETURN_GENERATED_KEYS);
            pstm.setString(1, l.getTitulo());
            pstm.setString(2, l.getSubtitulo());                        
            pstm.setString(3, l.getPalavrasChave());
            pstm.setDouble(4, l.getPreco());
            pstm.setDouble(5, l.getRoyalty());
            pstm.setString(6, l.getResumo());
            pstm.setInt(7, l.getEdicao());                       
            pstm.setDouble(8, l.getVolume());
            pstm.setInt(9, l.getQtEstoque());
            pstm.setInt(10, l.getIsbn());
            pstm.setInt(11, l.getEditor().getId_editor());
            pstm.setInt(12, l.getLoja().getId_loja());
            pstm.setInt(13, l.getAutor().getId_autor());
            pstm.execute();
            try(ResultSet rs = pstm.getGeneratedKeys()){
                if(rs.next()){
                    retorno = rs.getInt(1);
                }
            }
        }catch(Exception e){
            JOptionPane.showMessageDialog(null,"Erro ao adicionar um cadastro "+ e);
        }finally{
            try{
                ConnectionFactory.closeConnection(conn, pstm);
            }catch (Exception e){
               JOptionPane.showMessageDialog(null,"Erro ao desconectar com o banco " + e);
            }
        }
        return retorno;
    }