Informatica

Páginas: 4 (807 palabras) Publicado: 5 de diciembre de 2011
jIngreso
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jIngreso.java
 *
 * Created on 25/08/2011, 08:43:58 AM
 */

packagepaqControl;
import java.sql.*;
import javax.swing.*;
/**
 *
 * @author raul
 */
public class jIngreso extends javax.swing.JDialog {
    static Connection conn=null;
    static Statementst=null;
    static ResultSet rs=null;
    DefaultComboBoxModel modelo1= new DefaultComboBoxModel();
    static String bd="proyecto";
    static String login="root";
    static String pw="";
   @SuppressWarnings("StaticNonFinalUsedInInitialization")
static String url="jdbc:mysql://127.0.0.1:3306/"+bd;
     public static Connection Enlace(Connection conn)throws SQLException{
try{Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection(url,login,pw);
}
catch(ClassNotFoundException c){
}
return conn;
}

    /** Creates new form jIngreso */
    publicjIngreso(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
         //Se conecta el ComboBox con la base de datos
jComboBox1.setModel(modelo1);
try{conn=Enlace(conn);
st=conn.createStatement();
//Se hace la consulta SQL
rs=st.executeQuery("Select * from Usuarios");
//Se llena el Combo con los registros
while(rs.next()){
// el (2) representa lacolumna de la tabla
modelo1.addElement(rs.getString(2));
}
rs.close();
}
catch(SQLException c){
JOptionPane.showMessageDialog(null,"Error"+c.getMessage());
}

}
    

    /** This method iscalled 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.
     */
   @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jComboBox1 = new...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Informatica
  • Informatica
  • Informatica
  • Informatica
  • Informatica
  • Informática
  • Informatica
  • Informatica

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS