Subject Help sql.Date (I think)
Author Francisco Vieira
Please, does anybody know why I get his error?
I have a JTextField named textoIdentificador when this field lost the focus I have a code in the event the checks if the number typed does exist in the table CLIENTES, if doesn't I do prepare the fields to insert into the table (calling a Stored Procedure with 38 arguments).
 
The problem is even then number not existing in the table I get the following ERROR (maybe something about dates, I have 2 dates fields in the table):
 
java.lang.IllegalArgumentException
        at java.sql.Date.valueOf(Date.java:100)
        at org.firebirdsql.jdbc.FBDateField.setString(FBDateField.java:80)
        at org.firebirdsql.jdbc.FBPreparedStatement.setString(FBPreparedStatement.java:211)
        at clientes.textoIdentificadorFocusLost(clientes.java:1343)
        at clientes.access$5900(clientes.java:22)
        at clientes$65.focusLost(clientes.java:818)
        at java.awt.AWTEventMulticaster.focusLost(AWTEventMulticaster.java:168)
        at java.awt.Component.processFocusEvent(Component.java:4928)
        at java.awt.Component.processEvent(Component.java:4810)
        at java.awt.Container.processEvent(Container.java:1525)
        at java.awt.Component.dispatchEventImpl(Component.java:3527)
        at java.awt.Container.dispatchEventImpl(Container.java:1582)
        at java.awt.Component.dispatchEvent(Component.java:3368)
        at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1700)
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:709)
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:442)
        at java.awt.Component.dispatchEventImpl(Component.java:3397)
        at java.awt.Container.dispatchEventImpl(Container.java:1582)
        at java.awt.Component.dispatchEvent(Component.java:3368)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
 
and this is the code in my FocusLost event:
   private void textoIdentificadorFocusLost(java.awt.event.FocusEvent e) {
        // Add your handling code here:
        int tamid = textoIdentificador.getText().length();
        String tipo = (tamid==11 ? "CPF" : tamid==14 ? "CNPJ":"");
      
        if (tamid==11)
        {
            if (T.getNew().vCPF(textoIdentificador.getText()))
            {
                textoIdentificador.setText(T.getNew().formataCPF(textoIdentificador.getText()));
                comboTipoCliente.setSelectedIndex(1);
                LRG_IE.setText("RG");
 
                if (T.getNew().fbdriver())
                {
                    try
                    {
                        Connection c = DriverManager.getConnection(T.getNew().url()+T.getNew().db(),T.getNew().user(),T.getNew().pwd());
                        stmt = c.createStatement();
                        rst = stmt.executeQuery("SELECT * FROM CLIENTES WHERE IDCNPJ_CPF='"+textoIdentificador.getText()+"'");
                        if (rst.next())
                        {
                            T.getNew().Aviso(null, "ESTE CLIENTE JÁ ESTÁ CADASTRADO, Achou: "+rst.getShort("IDCNPJ_CPF"));
                            c.close();
                        }
                        else
                        {
                            c.close();
                            try
                            {
                                String tipoCliente = ((String)comboTipoCliente.getSelectedItem()).substring(0,1);
                                String UF = (String)comboEstados1.getSelectedItem();
                                String UFE = (String)UFEntrega.getSelectedItem();
                                String UFC = (String)UFCobranca.getSelectedItem();
                               
                                c = DriverManager.getConnection(T.getNew().url()+T.getNew().db(),T.getNew().user(),T.getNew().pwd());
                                CallableStatement p = 
                                c.prepareCall("{call CAD_CLIENTE(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?, ?, ?) }");
                                p.setString(1, textoIdentificador.getText());        
                                p.setString(2, textoRG_IE.getText());        
                                p.setString(3, tipoCliente);  
                                p.setString(4, dataCadastro.getText());        
                                p.setString(5, textoRazaoSocial.getText());        
                               
                                p.setString(6, textoEndereco.getText());        
                                p.setString(7, textoBairro.getText());        
                                p.setString(8, textoCidade.getText());        
                                p.setString(9, UF);        
                                p.setString(10, textoCEP.getText());        
                               
                                p.setString(11, textoTelefone.getText());        
                                p.setString(12, textoFAX.getText());        
                                p.setString(13, textoEmail.getText());        
                                p.setString(14, textoHomePage.getText());        
                                p.setString(15, textoNomeFantasia.getText());        
                                p.setString(16, textoPaginaDoGuia.getText());        
                                p.setString(17, textoCodVendedor.getText());        
                                p.setString(18, textoContato.getText());        
 
                                p.setString(19, enderecoEntrega.getText());        
                                p.setString(20, bairroEntrega.getText());        
                                p.setString(21, cidadeEntrega.getText());        
                                p.setString(22, CEPEntrega.getText());        
                                p.setString(23, UFE);        
 
                                p.setString(24, enderecoCobranca.getText());        
                                p.setString(25, bairroCobranca.getText());        
                                p.setString(26, cidadeCobranca.getText());        
                                p.setString(27, CEPCobranca.getText());        
                                p.setString(28, UFC);        
                               
                                p.setDouble(29, Double.parseDouble(textoFreteMinimo.getText()));        
                                p.setDouble(30, Double.parseDouble(textoDesconto.getText()));        
                                p.setDouble(31, Double.parseDouble(textoDescontoNF.getText()));        
                                p.setInt(32, Integer.parseInt(textoCodTarifa1.getText()));        
                                p.setInt(33, Integer.parseInt(textoCodTarifa2.getText()));        
                                p.setString(34, textoCFOP.getText());        
 
                                p.setString(35, textoDataAceite.getText());        
                                p.setString(36, textoTipoCliente.getText());       
                                p.setDouble(37, Double.parseDouble(textoAliquotaICMS.getText()));        
                                p.setString(38, textoObservacao.getText());        
                                p.execute();
                            }
                            catch (SQLException sqle1)
                            {
                              T.getNew().Aviso("Erro: Cadastrando cliente", sqle1.getMessage());                           
                            }
                        }
                    }
                    catch (SQLException sqle)
                    {
                        T.getNew().Aviso("Erro: Procurando CPF", sqle.getMessage());
                    }
                } // if do fbdriver
            } // if do validador do CPF
            else
            {
                T.getNew().Aviso("Erro", "O número do CPF está errado!");
                textoIdentificador.requestFocus();
            }
        }
        else if (tamid==14)
        {
            if (T.getNew().vCNPJ(textoIdentificador.getText()))
            {
                textoIdentificador.setText(T.getNew().formataCNPJ(textoIdentificador.getText()));
                comboTipoCliente.setSelectedIndex(0);
                LRG_IE.setText("IE");
                 
            }
            else
            {
                T.getNew().Aviso("Erro", "O número do CNPJ está errado!");
                textoIdentificador.requestFocus();
            }
        }
        else // hem eh igual a 11 nem igual a 14
        {
            // tamanho invalido mostrar mensagem ou tratar essa possibilidade
        }
 
    }
PS. My system is a different language than English, I hope you all forgive me for this, but the main thing is always the same.
 
thank you very much