import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.sql.*;
public class Inscripcion extends JFrame
{
//declaracion de variables
JFrame main, main2;
JLabel lblname;
JTextField name;
static private Statement sql;
private ResultSet resultInsertar;
static JButton btn_ok;
//crea la interfaz grafica de usuario GUI (ves como le cambie el nombre)
public Inscripcion()
{
setSize(500,300); //Tamanio del formulario
setTitle("OTM"); //TItulo del formulario
setResizable(false); //Para que no sea redimensionable
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);//Para salir al cerrar
getContentPane().setLayout(null);
lblname = new JLabel("Nombre");
lblname.setBounds(50,100,100,23);
getContentPane().add(lblname);
name = new JTextField();
name.setBounds(155,100,200,23);
getContentPane().add(name);
btn_ok = new JButton("Ingresar");
btn_ok.setBounds(370,230, 100, 23);
getContentPane().add(btn_ok);
btn_ok.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try{
resultInsertar = sql.executeQuery("INSERT INTO name(Nombre) VALUES('" + name.getText() + "')");
}catch(SQLException a){System.out.println("Error" + a);}
}
});
}
//Metodo principal
public static void main(String args[])
{
String nana;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dbase = "jdbc:odbc:base";
Connection Conexion =DriverManager.getConnection(dbase);
sql = Conexion.createStatement();
ResultSet nombre = sql.executeQuery("SELECT * FROM name");
while(nombre.next()){
nana = nombre.getString("Nombre");
System.out.println(nana);
}
nombre.moveToInsertRow();
nombre.updateString("Nombre",)
nombre.close();
Conexion.close();
sql.close();
}catch(ClassNotFoundException e){
System.out.println("Clase no encontrada");
}
catch(SQLException e){
System.out.println(e);
}
System.out.println("Sin error al conectar ");
new Inscripcion().setVisible(true);
}
}