Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Basededatos;
- import Vista.MantenedorFuncionarios;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import java.util.*;
- import java.sql.ResultSet;
- import javax.swing.JOptionPane;
- import Vista.MantenedorFuncionarios;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- public class FuncionariosDB {
- public void agregarFun(){
- MantenedorFuncionarios frame = new MantenedorFuncionarios();
- try{
- Connection con=null;
- Class.forName("com.mysql.jdbc.Driver");
- con = DriverManager.getConnection("jdbc:mysql://localhost/empresa","root","");
- PreparedStatement st=con.prepareStatement("INSERT INTO funcionariobd(rut, nombre, fechaNacimiento, cargo, sueldo) VALUES (?,?,?,?,?)");
- st.setString(1, frame.getRut());
- st.setString(2, frame.getNom());
- st.setString(3, frame.getFecNac());
- st.setString(4, frame.getCargo());
- st.setString(5, frame.getSueldo());
- st.executeUpdate();
- st.close();
- JOptionPane.showMessageDialog(null,"Usuario Agregado");
- } catch (SQLException ex) {
- Logger.getLogger(MantenedorFuncionarios.class.getName()).log(Level.SEVERE, null, ex);
- } catch (ClassNotFoundException ex) {
- Logger.getLogger(FuncionariosDB.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
Add Comment
Please, Sign In to add comment