Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- Class.forName("com.mysql.jdbc.Driver");
- java.sql.Connection conexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/tienda","root","");
- String nombre = textField_1.getText();
- int precio = Integer.parseInt(textField_2.getText());
- String descripcion = textArea.getText();
- JTextField textField_3 = new JTextField();
- SimpleDateFormat form = new SimpleDateFormat("dd/MM/yyyy");
- String query = "INSERT INTO productos (nombre,precio,descripcion) values('"+nombre+"','"+precio+"','"+descripcion+"')";
- Statement s = conexion.createStatement();
- s.executeUpdate(query);
- JOptionPane.showMessageDialog(null, "Nombre agregado");
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "Error");
- // TODO: handle exception
- }
- }
- });
Add Comment
Please, Sign In to add comment