You are on page 1of 2

package hospital;

import java.sql.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class cliente extends javax.swing.JFrame


{
private conexion mdbc;
private java.sql.Statement stmt;

public cliente() throws SQLException


{
initComponents();
mdbc=new conexion();
mdbc.init();
Connection con=mdbc.getMyConnection();
stmt=con.createStatement();

}
public void mostrar()
{
try
{
x=stmt.executeQuery("select *from cliente");
x.next();
mostrarprimero(x);
}
catch (SQLException e)
{
e.printStackTrace();
}
}

public void mostrarprimero(ResultSet x) throws SQLException


{
jT_id.setText(x.getString("id"));
jT_nombre.setText(x.getString("nombre"));
}

private void jB_mostrarActionPerformed(java.awt.event.ActionEvent evt) {

mostrar();
}

public static void main(String args[]) {


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
new cliente().setVisible(true);
} catch (SQLException ex) {
Logger.getLogger(cliente.class.getName()).log(Level.SEVERE,
null, ex);
}
}
});
}

// Variables declaration - do not modify


private javax.swing.JButton jB_mostrar;
private javax.swing.JTextField jT_id;
private javax.swing.JTextField jT_nombre;
// End of variables declaration
ResultSet x=null;

You might also like