Dúvida em JComboBox e Banco de Dados. Como gravar o registro mantendo relacionamento?

Bom dia a todos!

Minha dúvida é a seguinte. Eu tenho um cadastro de fabricante. O usuário irá inserir os fabricantes de seus produtos, e depois, quando ele precisar realizar uma venda, o cadastro de fabricantes será puxado através de um JComboBox. Até aí tudo bem. O problema é, depois que ele decidir cadastrar mais fabricantes ( ou não ) o cadastro de fabricantes está sendo ordenado, então, por exemplo:

Se ele cadastrar os Fabricantes Fiat e Wolkswagem, os códigos deles serão respectivamente 1 e 2, devido à ordem de inserção no bd.
Supondo que ele registre um produto usando o fabricante Wolkswagem, e depois ele cadastre um Fabricante Audi, quando ele tirar o relatório, como estou usando o .getSelectedIndex();, o código na tabela de vendas, continuará sendo 2, sendo que quando eu faço o order by, ele acabaria sendo o terceiro.

Resumindo, meu código não está mantendo a integridade, com os fabricantes cadastrados. Como posso resolver isto??

Segue abaixo o meu código do JComboBox que puxa os cadastros de fabricante.

[code]try{
String Driver = “org.postgresql.Driver”;
String local = “127.0.0.1”;
String ConnecString = “jdbc:postgresql://” + local +":5432/bd";
String user = “";
String pass = "
***”;
Class.forName(Driver).newInstance();
Connection connection = DriverManager.getConnection(ConnecString, user, pass);
Statement ConsultaSQL = connection.createStatement();
ResultSet rs;
jcbFabricante.removeAllItems();
int x;
rs = ConsultaSQL.executeQuery
(“SELECT nome_fabricante FROM fabricante ORDER BY nome_fabricante ASC”);
try{
while(rs.next()){
jcbFabricante.addItem(rs.getString(1));
}

      } catch(Exception err){
         err.printStackTrace();
      }

}[/code]

PS: eu já tive a idéia de fazer com que depois do usuário selecionar o fabricante, eu dar um select pegando o nome que está selecionado no JComboBox, mas aí eu não consegui desenvolver o método…
Agradeço a todos que puderem me ajudar.
Até mais.

Você precisa utilizar o ID que vem do seu banco para gravar como chave de relacionamento, e não o selectedIndex do combo.

Olha, pelo que sei de um combobox do swing, vc não tem como colocar um valor para ID no item. Porem, um item recebe um objeto, então uma solução mais elegante, seria você criar um objeto ComboItem. (sinceramente não sei se o swing, já não tem algo assim, não costumo trabalhar com swing). Mas enfim, ficaria uma solução assim:

public class ComboItem{
   private String id;
   private String label;
   
   public ComboItem(String id, String label)
   {
       this.id = id;
       this.label = label;
    }

   //getter and setter
   public String toString()
   {
      return this.label;
    }
}

E no seu combo vc adicionaria estes itens

 ResultSet rs;  
jcbFabricante.removeAllItems();  
int x;  
rs = ConsultaSQL.executeQuery  
    ("SELECT id_fabricante, nome_fabricante FROM fabricante ORDER BY nome_fabricante ASC");  
try{  
   while(rs.next()){  
      jcbFabricante.addItem(new ComboItem(rs.getString(1),rs.getString(2));  
   }  
     
} catch(Exception err){  
   err.printStackTrace();  
}

E depois, ao invés de vc utilizar o getSelectedIndex, vc utiliza o método getSelectedItem(), mais ou menos assim:

ComboItem itemSelecionado = (ComboItem)jcbFabricante.getSelectedItem();
itemSelecionado.getId();

Valeu.

Juliano Carniel , eu dei uma olhada rápida e fiz algumas modificações, mas como estou meio garrado (estou em treinamento como Analista de Suporte), amanhã a noite devo estar com mais tempo, então se der eu já posto minha resposta pra ver se deu certo ou não.

Obrigado pela atenção.

Juliano Carnel, esta função

itemSelecionado.getId();

não fica disponível com estas alterações que realizei. Tem outro método que retorna o id selecionado??

Edit: Juliano, depois de fazer estas alterações, meu

ComboItem fabricante = (ComboItem)jcbFabricante.getSelectedItem();

Não consegue retornar valor para ser inserido no banco de dados. Cara, será que vc não tem uma classe que tem este processo não? To na maior dúvida sobre isto…

Pessoal, ainda não consegui resolver isto, ninguém aí tem uma solução não???
Ainda preciso de ajuda!

[quote=gustavogoncalves]Pessoal, ainda não consegui resolver isto, ninguém aí tem uma solução não???
Ainda preciso de ajuda![/quote]

O exemplo do Juliano está correto, quais modificações vc realizou? poste a classe com as modificações para analisarmos!

rafael_ra, vc leu o que eu digitei em comments anteriores??

Eu já fiz as modificações que o Juliano solicitou, mas ainda assim não fax com que eu consiga inserir o código do registro, ao inves do selectedIndex. Sem falar, que não consigo fazer o procedimento que ele me pediu para colocar o

itemSelecionado.getId();

Pois o .getID() não fica disponível para mim. Resumindo, pode até dar certo, só que ele disse que não sabia se o swing funcionava desta maneira, eu preciso de fazer isto usando o swing.

Resumindo: já fiz as alterações que ele já havia solicitado para que eu fizesse, mas ainda assim não consigo fazer o que havia perguntado no início do post.

Já que solicitado, segue a classe com as alterações.


/*
 * jfCadastroJogos.java
 *
 * Created on 27 de Janeiro de 2008, 12:06
 */

package cadastrojogos;

import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;

/**
 *
 * @author  Gustavo
 */
public class jfCadastroJogos extends javax.swing.JFrame {
    
    /**
     * Creates new form jfCadastroJogos
     */
    public jfCadastroJogos()  {
        initComponents();
        
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Código Gerado ">                          
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jcbPlataforma = new javax.swing.JComboBox();
        jcbGenero = new javax.swing.JComboBox();
        jtJogo = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jcbClassificacao = new javax.swing.JComboBox();
        jcbJogadores = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtaDicas = new javax.swing.JTextArea();
        jLabel9 = new javax.swing.JLabel();
        jbNovo = new javax.swing.JButton();
        jbSalvar = new javax.swing.JButton();
        jbBuscar = new javax.swing.JButton();
        jbSair = new javax.swing.JButton();
        jbExcluir = new javax.swing.JButton();
        jcbFabricante = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Cadastro de Jogos");
        setExtendedState(MAXIMIZED_BOTH);
        jLabel1.setText("Nome");

        jLabel2.setText("Genero");

        jLabel4.setText("Plataforma");

        jcbPlataforma.setToolTipText("Plataforma Operacional");

        jcbGenero.setToolTipText("Genero do Jogo");

        jtJogo.setToolTipText("Cadastre o Nome do Jogo");
        jtJogo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jtJogoFocusGained(evt);
            }
        });

        jLabel5.setText("Jogadores");

        jLabel6.setText("Classificacao");

        jLabel3.setText("Fabricante");

        jcbClassificacao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1 - Ruim", "2 - Bom", "3 - \u00d3timo", "4 - Excelente!" }));
        jcbClassificacao.setToolTipText("O jogo \u00e9 bom??");

        jcbJogadores.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1 Jogador", "2 Jogadores", "3 Jogadores", "4 Jogadores" }));
        jcbJogadores.setToolTipText("Quantidade de Jogadores");

        jLabel8.setText("Dicas:");

        jtaDicas.setColumns(20);
        jtaDicas.setRows(5);
        jtaDicas.setToolTipText("Cadastre as dicas deste jogo");
        jScrollPane1.setViewportView(jtaDicas);

        jLabel9.setFont(new java.awt.Font(">Arial", 0, 12));
        jLabel9.setText("Limite de 400 Caracteres!");

        jbNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cadastrojogos/icons/novo.gif")));
        jbNovo.setMnemonic('N');
        jbNovo.setText("Novo");
        jbNovo.setToolTipText("Novo registro");
        jbNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbNovoActionPerformed(evt);
            }
        });

        jbSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cadastrojogos/icons/salvar.gif")));
        jbSalvar.setMnemonic('S');
        jbSalvar.setText("Salvar");
        jbSalvar.setToolTipText("Salve este registro");
        jbSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbSalvarActionPerformed(evt);
            }
        });

        jbBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cadastrojogos/icons/buscar.gif")));
        jbBuscar.setMnemonic('B');
        jbBuscar.setText("Buscar");
        jbBuscar.setToolTipText("Buscar registro");
        jbBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBuscarActionPerformed(evt);
            }
        });

        jbSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cadastrojogos/icons/desligar.gif")));
        jbSair.setMnemonic('F');
        jbSair.setText("Fechar");
        jbSair.setToolTipText("Fechar esta janela");
        jbSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbSairActionPerformed(evt);
            }
        });

        jbExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cadastrojogos/icons/lixeira.gif")));
        jbExcluir.setMnemonic('E');
        jbExcluir.setText("Excluir");
        jbExcluir.setToolTipText("Excluir um registro");
        jbExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbExcluirActionPerformed(evt);
            }
        });

        jcbFabricante.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jcbFabricanteFocusGained(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel8)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel4)
                            .addComponent(jLabel1))
                        .addGap(4, 4, 4)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jtJogo, javax.swing.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE)
                            .addComponent(jcbGenero, 0, 403, Short.MAX_VALUE)
                            .addComponent(jcbPlataforma, 0, 403, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jcbJogadores, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jcbClassificacao, javax.swing.GroupLayout.Alignment.TRAILING, 0, 414, Short.MAX_VALUE)
                            .addComponent(jcbFabricante, 0, 414, Short.MAX_VALUE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel9))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(330, 330, 330)
                        .addComponent(jbNovo, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbBuscar))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(381, 381, 381)
                        .addComponent(jbExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbSair, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel3)
                    .addComponent(jcbFabricante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtJogo, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel5)
                    .addComponent(jcbJogadores, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcbGenero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel6)
                    .addComponent(jcbClassificacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcbPlataforma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addGap(0, 0, 0)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 426, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel9)
                .addGap(5, 5, 5)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbNovo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbSair, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jLabel10.setFont(new java.awt.Font("Arial", 1, 14));
        jLabel10.setText("Cadastro de Jogos");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(24, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(447, 447, 447)
                .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
                .addGap(382, 382, 382))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(41, 41, 41))
        );
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-994)/2, (screenSize.height-768)/2, 994, 768);
    }// </editor-fold>                        
    
    private void jtJogoFocusGained(java.awt.event.FocusEvent evt) {                                   
// TODO adicione seu código de manipulação aqui:
        try{
            String Driver = "org.postgresql.Driver";
            String local = "127.0.0.1";
            String ConnecString = "jdbc:postgresql://" + local +":5432/games";
            String user = "*******";
            String pass = "*******";
            Class.forName(Driver).newInstance();
            Connection connection = DriverManager.getConnection(ConnecString, user, pass);
            Statement ConsultaSQL = connection.createStatement();
            ResultSet rs;
            jcbFabricante.removeAllItems();
            int x;
            rs = ConsultaSQL.executeQuery
                    ("SELECT id_fabricante, nome_fabricante " +
                    "FROM fabricante ORDER BY nome_fabricante ASC");
            try{
                while(rs.next()){
                    jcbFabricante.addItem(new ComboItem(rs.getString(1), rs.getString(2)));
                }
                
            } catch(Exception err){
                err.printStackTrace();
            }
            jcbFabricante.updateUI();
            rs = ConsultaSQL.executeQuery
                    ("SELECT nome_genero FROM genero ORDER BY nome_genero ASC");
            try{
                while (rs.next())
                    jcbGenero.addItem(rs.getString(1));
            } catch (Exception err){
                err.printStackTrace();
            }
            jcbGenero.updateUI();
            rs = ConsultaSQL.executeQuery
                    ("SELECT id_plataforma, nome_plataforma " +
                    "FROM plataforma ORDER BY nome_plataforma ASC");
            try{
                while(rs.next()){
                    jcbPlataforma.addItem(new ComboItem(rs.getString(1), rs.getString(2)));
                }
            } catch (Exception err){
                err.printStackTrace();
            }
            jcbPlataforma.updateUI();
            rs.close();
        }catch(Exception err){
            err.printStackTrace();
        }
        
    }                                  
    
    public class ComboItem{
        private String id;
        private String label;
        
        public ComboItem(String id, String label) {
            this.id = id;
            this.label = label;
        }
        
        //getter and setter
        public String toString() {
            return this.label;
        }
    }
    
    private void jcbFabricanteFocusGained(java.awt.event.FocusEvent evt) {                                          
        
    }                                         
    
    private void jbExcluirActionPerformed(java.awt.event.ActionEvent evt) {                                          
        Object Evento = evt.getSource();
        if (Evento == jbExcluir){
            jfCadDeletar CadDeletar = new jfCadDeletar();
            CadDeletar.setVisible(true);
            CadDeletar.show();
            
        }
    }                                         
    
    private void jbSairActionPerformed(java.awt.event.ActionEvent evt) {                                       
        Object Evento = evt.getSource();
        if (Evento == jbSair){
            this.dispose();
        }
    }                                      
    
    private void jbBuscarActionPerformed(java.awt.event.ActionEvent evt) {                                         
        Object Evento = evt.getSource();
        if (Evento == jbBuscar){
            jfBuscar Buscar = new jfBuscar();
            Buscar.setVisible(true);
            Buscar.show();
            this.dispose();
        }
    }                                        
    
    private void jbSalvarActionPerformed(java.awt.event.ActionEvent evt) {                                         
        String str_jogo = "";
        String verifica_nome = "";
        String nome_jogo = jtJogo.getText().trim();
        ComboItem fabricante = (ComboItem)jcbFabricante.getSelectedItem();
        
        
        //int fabricante = jcbFabricante.getSelectedIndex();
        int genero = jcbGenero.getSelectedIndex();
        int jogadores = jcbJogadores.getSelectedIndex();
        int plataforma = jcbPlataforma.getSelectedIndex();
        int classificacao = jcbClassificacao.getSelectedIndex();
        String dicas = jtaDicas.getText().trim();
        int id_nome = 0;
        int x;
        try{
            String Driver = "org.postgresql.Driver";
            String local = "127.0.0.1";
            String ConnecString = "jdbc:postgresql://" + local +":5432/games";
            String user = "*******";
            String pass = "*******";
            Class.forName(Driver).newInstance();
            Connection connection = DriverManager.getConnection(ConnecString, user, pass);
            Statement ConsultaSQL = connection.createStatement();
            ResultSet rs;
            rs = ConsultaSQL.executeQuery("select id_fabricante, nome_fabricante from jogos " +
                    "where nome_fabricante = " + fabricante + "' order by");
            if ((nome_jogo.length() == 0 )){
                JOptionPane.showMessageDialog
                        (null, "Digite os campos necessarios!.");
            } else{
                rs = ConsultaSQL.executeQuery("SELECT nome FROM jogos WHERE nome = '" + nome_jogo + "'");
                while(rs.next()){
                    verifica_nome = rs.getString(1);
                }
                if (verifica_nome == nome_jogo){
                    
                    rs = ConsultaSQL.executeQuery("select id_nome from jogos where nome = '" + nome_jogo + "'");
                    try{
                        while(rs.next())
                            str_jogo = rs.getString(1);
                        id_nome = Integer.parseInt(str_jogo);
                    } catch (Exception err){
                        err.printStackTrace();
                    }
                    id_nome = id_nome+1;
                    x = ConsultaSQL.executeUpdate("update jogos " +
                            "set nome  = '" + nome_jogo + "', " +
                            "fabricante = '" + fabricante + "', " +
                            "genero = '" + genero + "', " +
                            "jogadores = '" + jogadores + "', " +
                            "plataforma = "+ plataforma + "', " +
                            "classificacao = "+ classificacao + "', " +
                            "dicas = " + dicas + "' where id_nome = '" + id_nome + "'");
                    if (x == 1){
                        JOptionPane.showMessageDialog
                                (null, "Registro " + nome_jogo +  " atualizado com sucesso.", "Informacao", 1);
                    } else {
                        JOptionPane.showMessageDialog
                                (null, "O Registro não foi atualizado. \n" +
                                "Entre em contato com o desenvolvedor!", "Erro!", 0);
                    }
                } else{
                    rs = ConsultaSQL.executeQuery
                            ("select max(id_nome) from jogos");
                    try{
                        while (rs.next()){
                            str_jogo = rs.getString(1);
                            id_nome = Integer.parseInt(str_jogo);
                        }
                        id_nome = id_nome++;
                    } catch(Exception err){
                        
                    }
                    rs = ConsultaSQL.executeQuery
                            ("insert into jogos (id_nome, nome, fabricante, genero, jogadores, " +
                            "plataforma, classificacao, dicas) values ('" +
                            id_nome + "', '" + nome_jogo + "', '" +
                            fabricante + "', '" + genero +"', '"
                            + jogadores + "', '"  + plataforma + "', '"
                            + classificacao + "' , '" + dicas + "')");
                    if (rs.next() == true){
                        JOptionPane.showMessageDialog(null, "Registro gravado com sucesso!");
                        jtJogo.setText("");
                        jcbFabricante.setSelectedIndex(0);
                        jcbGenero.setSelectedIndex(0);
                        jcbJogadores.setSelectedIndex(0);
                        jcbPlataforma.setSelectedIndex(0);
                        jcbClassificacao.setSelectedIndex(0);
                        jtaDicas.setText("");
                    } else {
                        JOptionPane.showMessageDialog(null, "Registro " + id_nome + "não pode ser gravado");
                    }
                    rs.close();
                    
                }
            }
        } catch (Exception err){
            err.printStackTrace();
        }
    }                                        
    
    private void jbNovoActionPerformed(java.awt.event.ActionEvent evt) {                                       
        Object Evento = evt.getSource();
        if (Evento == jbNovo){
            jtJogo.setText("");
            jcbFabricante.setSelectedIndex(0);
            jcbGenero.setSelectedIndex(0);
            jcbJogadores.setSelectedIndex(0);
            jcbPlataforma.setSelectedIndex(0);
            jcbClassificacao.setSelectedIndex(0);
            jtaDicas.setText("");
        }
    }                                      
    
    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jfCadastroJogos().setVisible(true);
            }
        });
    }
    
    // Declaração de variáveis - não modifique                     
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbBuscar;
    private javax.swing.JButton jbExcluir;
    private javax.swing.JButton jbNovo;
    private javax.swing.JButton jbSair;
    private javax.swing.JButton jbSalvar;
    private javax.swing.JComboBox jcbClassificacao;
    private javax.swing.JComboBox jcbFabricante;
    private javax.swing.JComboBox jcbGenero;
    private javax.swing.JComboBox jcbJogadores;
    private javax.swing.JComboBox jcbPlataforma;
    private javax.swing.JTextField jtJogo;
    private javax.swing.JTextArea jtaDicas;
    // Fim da declaração de variáveis                   
    
}

Partes modificadas:
classe:
private void jbSalvarActionPerformed

e

private void jtJogoFocusGained

O que modifiquei por enquanto, já que são outros itens é o jcbFabricante, como segue exemplo abaixo:

jcbFabricante.addItem(new ComboItem(rs.getString(1), rs.getString(2)));

Gustavo na sua classe ComboItem vc colocou os metodos getters??

public Integer getId(){
    return this.id;
}

se colocou nesse momento vc tem que buscar o id do ComboItem

x = ConsultaSQL.executeUpdate("update jogos " +   
                            "set nome  = '" + nome_jogo + "', " +   
                            "fabricante = '" + fabricante + "', " +   
                            "genero = '" + genero + "', " +   
                            "jogadores = '" + jogadores + "', " +   
                            "plataforma = "+ plataforma + "', " +   
                            "classificacao = "+ classificacao + "', " +   
                            "dicas = " + dicas + "' where id_nome = '" + id_nome + "'");   

na linha

"fabricante = '" + fabricante + "', " +  

muda para

"fabricante = '" + fabricante.getId + "', " +  

Acho que é este seu problema, qualquer coisa posta ae novamente.

rafael_ra e Juliano, obrigado pelas explicações. fiz a modificação aqui e deu certo. Tive que fazer uma ou duas mudanças além, mas deu certo.

Obrigado.