⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modificar.java

📁 ejemplo de java para conexion a base de datos
💻 JAVA
字号:
/* * modificar.java * * Created on 26 de junio de 2004, 02:48 AM *//** * * @author  GeBuSe */import javax.swing.table .*;import java.sql.*;public class modificar extends javax.swing.JDialog {    Connection acon;    /** Creates new form modificar */    public modificar(java.awt.Frame parent, boolean modal,Connection pcon) {        super(parent, modal);        initComponents();        setSize(500, 400);        acon=pcon;    }        /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    private void initComponents() {//GEN-BEGIN:initComponents        jButton1 = new javax.swing.JButton();        label1 = new java.awt.Label();        rutt = new javax.swing.JTextField();        p_nombre = new javax.swing.JTextField();        ap_paterno = new javax.swing.JTextField();        label2 = new java.awt.Label();        label3 = new java.awt.Label();        getContentPane().setLayout(null);        addWindowListener(new java.awt.event.WindowAdapter() {            public void windowClosing(java.awt.event.WindowEvent evt) {                closeDialog(evt);            }        });        jButton1.setText("modificar");        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton1ActionPerformed(evt);            }        });        getContentPane().add(jButton1);        jButton1.setBounds(130, 50, 120, 26);        label1.setText("Ingresa El Rut");        getContentPane().add(label1);        label1.setBounds(10, 20, 130, 20);        getContentPane().add(rutt);        rutt.setBounds(160, 20, 150, 20);        getContentPane().add(p_nombre);        p_nombre.setBounds(170, 90, 110, 20);        getContentPane().add(ap_paterno);        ap_paterno.setBounds(170, 170, 110, 20);        label2.setText("nombre");        getContentPane().add(label2);        label2.setBounds(30, 90, 130, 20);        label3.setText("apellido");        getContentPane().add(label3);        label3.setBounds(30, 170, 110, 20);        pack();    }//GEN-END:initComponents    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformedString rut;Statement stmt;ResultSet rs;String consulta;try{stmt = acon.createStatement();  consulta ="update persona set p_nombre='"+p_nombre.getText()+"', ap_paterno='"+ap_paterno.getText()+"' where rut='"+rutt.getText()+"'";stmt.executeUpdate(consulta);stmt.close();        }        catch (SQLException ex)        {            System.out.println("Hubo un error en la consulta ... :"+ex);        }     }//GEN-LAST:event_jButton1ActionPerformed        /** Closes the dialog */    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog        setVisible(false);        dispose();    }//GEN-LAST:event_closeDialog        /**     * @param args the command line arguments     */  /*  public static void main(String args[]) {        new modificar(new javax.swing.JFrame(), true).show();    }*/            // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JTextField ap_paterno;    private javax.swing.JButton jButton1;    private java.awt.Label label1;    private java.awt.Label label2;    private java.awt.Label label3;    private javax.swing.JTextField p_nombre;    private javax.swing.JTextField rutt;    // End of variables declaration//GEN-END:variables    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -