Olá pessoal,
resolvi meu pro com os frames falando com meu professor, mas absorvi muitas coisas com as dicas que recebi neste fórum. Por isso volto aqui pedido a ajuda de vocês agora com o botão grava do meu porjeto.
o código que uso para gravar o que eu quero é este:
if(JOptionPane.showConfirmDialog(this, "Deseja realmente salvar?")==JOptionPane.YES_NO_OPTION){
int cpf=Integer.parseInt(txtCpfF.getText());
Fisico f=dao.localizarCtF(cpf);
if(f==null){
f=new Fisico();
f.setCpf(cpf);
f.setNome(txtNomeF.getText());
f.setEmail(txtEmailF.getText());
f.setTelefone(txtTelefoneF.getText());
dao.gravarCtF(f);
}
else{
f.setCpf(Integer.parseInt(txtCpfF.getText()));
f.setNome(txtNomeF.getText());
f.setEmail(txtEmailF.getText());
f.setTelefone(txtTelefoneF.getText());
dao.atualizarCtF(f);
}
limparTexto();
}
assim, no BD o CPF é int… e ele reclama que estou tentanto gravar uma String, o que eu estou fazendo de errado no meu código?
na hora de executar ele não grava, da erro… aparece isso aqui
[EL Info]: 2011-01-03 13:00:19.053–ServerSession(3916375)–EclipseLink, version: Eclipse Persistence Services - 2.0.0.v20091127-r5931
[EL Info]: 2011-01-03 13:00:20.368–ServerSession(3916375)–file:/C:/Users/pc/Documents/NetBeansProjects/ProgramaColorPrinter/src/_ProgramaColorPrinterPU login successful
Exception in thread “AWT-EventQueue-0” java.lang.NumberFormatException: For input string: “64584757564”
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:461)
at java.lang.Integer.parseInt(Integer.java:499)
at bd.colorprinter.gui.FormFisico.btnSalvarFActionPerformed(FormFisico.java:200)
at bd.colorprinter.gui.FormFisico.access$000(FormFisico.java:22)
at bd.colorprinter.gui.FormFisico$1.actionPerformed(FormFisico.java:139)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6263)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6028)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
int: The int data type is a 32-bit signed two’s complement integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). For integral values, this data type is generally the default choice unless there is a reason (like the above) to choose something else. This data type will most likely be large enough for the numbers your program will use, but if you need a wider range of values, use long instead.
O número do cpf não cabe em uma variável do tipo int. Por isso dá uma erro na conversão da string para o int.
[quote=aluisiodsv]int: The int data type is a 32-bit signed two’s complement integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). For integral values, this data type is generally the default choice unless there is a reason (like the above) to choose something else. This data type will most likely be large enough for the numbers your program will use, but if you need a wider range of values, use long instead.
O número do cpf não cabe em uma variável do tipo int. Por isso dá uma erro na conversão da string para o int.
Use o tipo long.[/quote]
Está correto altera para o tipo long que aceita um tamanho muito maior.
Flw