O código abaixo não está inserindo dados digitados no banco, o que está faltando?
========
if(e.getSource()==B2) // gravar no banco de dados na tabela PratoBebida
{
int selection = JOptionPane.showConfirmDialog(null,“Deseja Cadastrar o referido Prato ou Bebida ?”,“Confirmação de Gravação do Prato&Bebida”,JOptionPane.OK_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE);
if (selection == JOptionPane.OK_OPTION) {
Connection con = null;
Statement stmt= null;
String nomeDoBanco ="jdbc:mysql://localhost/restaurantedapraia";
String usuario="root";
String senha="root";
try{
con = DriverManager.getConnection(nomeDoBanco,usuario,senha);
stmt = con.createStatement();
System.out.println("Conectado");
int codigo=Integer.parseInt(Tx1.getText());
String descricao = Tx2.getText();
double preco=Double.parseDouble(Tx3.getText());
String inserir = "INSERT INTO pratobebida (codigo,descricao,preco) VALUES ('"+codigo+"',"+descricao+"','"+preco+"')";
stmt.executeUpdate(inserir);
JOptionPane.showMessageDialog(null,""+"Novo prato incluído com sucesso!","Mensagem",1);
con.close();
stmt.close();
}
catch (SQLException ex) {
System.out.println(ex);
}
}
}
}
==============
Erro…
Conectado
Exception in thread “AWT-EventQueue-0” java.lang.NumberFormatException: For inpu
t string: “1,20”
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:12
24)
at java.lang.Double.parseDouble(Double.java:482)
at Insert_2_prato.actionPerformed(Insert_2_prato.java:138)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:18
49)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:234)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1766)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)