Beruflich Dokumente
Kultur Dokumente
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
PORTADA
UNIVERSIDAD TCNICA DE AMBATO
Facultad de Ingeniera en Sistemas, Electrnica e Industrial
Proyecto Acadmico de Fin de Semestre
Ttulo:
Creacin de una base de datos
Carrera:
Ingeniera Industrial en Procesos de
Automatizacin
rea Acadmica:
Informtica
Lnea de Investigacin:
Administracin
Ciclo Acadmico y paralelo:
Tercero Industrial B
Alumnos participantes:
Herrera Guayaquil Vicente David
Villagmez Garca Dennis Daniel
Mdulo y Docente:
II.
PP
YY
2.1 Ttulo
Creacin de una base de datos y consulta de tablas
2.2 Objetivos
2.2.1 General
Crear una base de datos que represente la facilidad de manipulacin de
informacin que stas brindan teniendo una buena estructura.
2.2.2 Especficos
Disear correctamente el modelo de la base de datos necesaria para el
sistema, definiendo sus restricciones y relaciones, en MySQL Workbench
6.3 CE.
Establecer la conexin a la Base phpMyAdmin con direccin
172.21.123.65/phpMyAdmin.
Realizar la ventana de consulta de datos en NetBeans.
2.3 Resumen
En el presente proyecto, se detalla la creacin de un modelo de base de datos en
MySQL Workbench, siendo este el Sistema Gestionador de Base de Datos
utilizado en el mdulo en curso. Dicha base contiene una simulacin de la gestin
de datos manejada en la Facultad, involucrando las carreras, personas en general,
cargos, y datos de la facultad.
Adems se da a conocer los procesos estndar de normalizacin de bases de
datos para evitar problemas y optimizar espacios, siendo as un paso importante
para la obtencin de un base de datos funcional.
El espacio fsico ha sido creado en phpMyAdmin, siendo este otorgado por el
docente exclusivamente para cada estudiante, al cual se tiene acceso por medio
de la red FISEI nicamente en su espacio de cobertura.
Las ventanas de consultas han sido creadas en NetBeans, ya que es el entorno de
desarrollo integrado libre que se ha estudiado en cursos anteriores.
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
ATRIBUTOS CORRESPONDIENTES
Cada elemento en una tabla establecida posee atributos, que son las
caractersticas con las cuales se describe una entidad. Los atributos
correspondientes a dicha entidad la vuelven nica, es decir que sin importar
cuntas entidades haya, cada una es completamente diferente a las dems. En
una estructura de tabla, cada fila representa una entidad y cada columna sus
atributos.
ATRIBUTOS DE TABLAS
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
Cada tabla individual debe ser independiente en cada conjunto de datos que en
ella se relacione, sus atributos deben ser bien ubicados con cada entidad
correspondiente, para lo cual es necesario eliminar grupos repetidos e identificar
cada conjunto de datos relacionado con una clave principal, evitando errores en la
manipulacin de informacin. La definicin de atributos de una tabla debe ser
nica, es decir, no debe haber grupos de repeticin que puedan dar apertura a la
redundancia notable de datos. Es esencial tener en cuenta que una correcta tabla
de datos solo tiene dos dimensiones, que involucran entidades y atributos. [1]
PASOS DE NORMALIZACIN
Primera forma normal
Eliminar grupos repetidos en tablas individuales.
Crear una tabla independiente para cada conjunto de datos relacionados.
Identificar cada conjunto de datos relacionados con una clave principal.
La segunda forma normal
Crear tablas independientes para conjuntos de valores que se apliquen a varios
registros.
Relacione estas tablas con una clave externa.
La tercera forma normal
Elimine los campos que no dependan de la clave.
TIPOS DE DATOS
Despus de la fase de diseo de una base de datos, y una vez se ha realizado el
paso a tablas del mismo, en necesario crear las tablas correspondientes dentro de
la base de datos. Para cada campo de cada una de las tablas, es necesario
determinar el tipo de datos que contiene para de esa forma ajustar el diseo de la
base de datos y conseguir un almacenamiento ptimo con la menor utilizacin de
espacio. MySQL distingue una serie de tipos de datos que podremos utilizar a la
hora de crear los campos que formarn nuestras tablas. [2]
Tipo texto
Char(x)
Tipo de datos que admite caracteres alfanumricos. La longitud de este campo
vara entre 1-255 y est delimitado a la longitud especificada entre parntesis (x)
en el momento de la creacin del campo de la tabla. Al introducir datos en este
campo siempre se solicitar el nmero de caracteres especificados. Si creamos un
campo con Char (5) deberemos introducir cinco caracteres cada vez que
incluyamos un dato en ese campo. Si incluimos menos, mySQL rellenar los
caracteres que faltan hasta el nmero indicado con espacios.
Varchar(x)
Tipo de datos que admite caracteres alfanumricos. Su uso es similar a Char(x). A
la hora de definir un campo de datos Varchar deberemos especificar el nmero
mximo de caracteres que podr aceptar en la entrada de datos, donde x es un
nmero entre 1-255. A diferencia de Char, este tipo de datos es variable en su
longitud, admitiendo entradas inferiores a la establecida.
Text, TintyText, MediumText, LongText
Mediante la declaracin de este tipo de datos se admiten la inclusin de cadenas
alfanumricas "case-insensitive" de longitudes variables. TinyText admite un
mximo de 255 caracteres, Text admite 65.535, MediumText permite introducir
textos de hasta 16.777.215 caracteres, LongText nos ofrece la posibilidad de incluir
un mximo de 4.294.967.295 caracteres. Estos campos no necesitan de
especificaciones de longitud a la hora de ser declarados.
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
Tipo binario
Blob
Un tipo de datos Blob es un objeto binario que puede almacenar cualquier tipo de
datos o informacin, desde un archivo de texto con todo su formato (se diferencia
en esto de tipo Text) hasta imgenes, archivos de sonido o video, etc. Al igual que
el tipo Text, Blob admite hasta 65.535 caracteres.
TinyBlob, MediumBlob, LongBlob
Son datos del mismo tipo que el anterior pero que varan en cuanto a su tamao,
as TinyBlob admite hasta 255 caracteres mximo, MediumBlob acepta tamaos
de hasta 16.777.215 de caracteres y LongBlob 4.294.967.295 caracteres (como
vemos estos tamaos se corresponden con los de TinyText, MediumText y
LongText).
Tipo numrico
Int
Este es un tipo de datos numricos de tipo entero. Este tipo de datos guarda
valores enteros (no decimales) entre -2.147.483.648 y 2.147.483.647. TinyiInt,
SmallInt, MediumInt, BigInt Son tipos de datos numricos enteros (no decimal).
TinyiInt agrupa un rango de nmeros entre -128 y 127. SmallInt alcanza desde
-32.768 hasta 32.767. MediumInt tiene un rango comprendido entre -8.388.608 y
8.388.607. Finalmente el tipo de datos BigInt ocupa un rango numrico entre
-9.223.372.036.854.775.808 hasta 9.223.372.036.854.775.807.
Float (M, D)
Nmero de coma flotante de precisin simple. El valor del argumento M nos indica
el nmero de dgitos decimales que se van a utilizar para representar el nmero.
As, un valor de 5 nos permitir representar nmeros comprendidos entre -99 y 99
(Nmeros expresados en binario con 5 dgitos y signo). El valor del argumento D
nos indica el nmero de posiciones decimales que se van a utilizar en la
representacin del nmero. As, una representacin tipo Float (5,2) nos permitir
incluir nmeros entre -99,99 y 99,99. El rango de los nmeros de coma flotante de
precisin simple es de -3,402823466E+38 a -1,175494351E-38, 0, y
1,175494351E- 38 hasta 3,402823466E+38.
Double (M, D)
Nmero de coma flotante de precisin doble. Es un tipo de datos igual al anterior
cuya nica diferencia es el rango numrico que abraca, siendo este el
comprendido entre 1,7976931348623157E+308 hasta -2,.2250738585072014E308, 0, y 2,2250738585072014E-308 to 1,7976931348623157E+308
Decimal (M, D)
Su uso es similar al de los anteriores, pero, en este caso, D puede tener valor 0. El
rango de este nmero es el mismo que el de nmero con coma flotante de
precisin doble.
Tipo fecha- hora
Date
Formato de Fecha. Su representacin es en formato de fecha numrica del tipo
'YYYY-MM-DD' (Ao con cuatro dgitos, Mes con dos dgitos, da con dos dgitos).
Su rango es '1000-01-01' (1 de enero del ao 1000, en el cual yo era an muy
pequeo) hasta '9999-12-31' (31 de diciembre del 9999, que ya veremos qu pasa
despus de las uvas).
Date Time
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
Lo primero que se debe realizar para poder conectarse a una base de datos es
cargar el driver encargado de sta funcin. Para ello es utilizada la
llamada Class.forName.
Class.forName ("DriverXYZ");
Donde DriverXYZ corresponde al driver a cargar, por ejemplo, el driver JDBCODBC
es sun.jdbc.odbc.JdbcOdbcDriver;
el
driver
JDBC-MySQL
es com.mysql.jdbc.Driver.
Una vez cargado el driver es necesario crear un objeto del tipo Connection, para
administrar la conexin. Una aplicacin puede utilizar DriverManager para obtener
un objeto de tipo conexin, Connection, con una base de datos. La conexin se
especifica siguiendo una sintaxis basada en la especificacin ms amplia de los
URL, de la forma:
Jdbc: subprotocolo//servidor: puerto/base de datos
La siguiente lnea de cdigo ilustra sta idea:
Connection con = DriverManager.getConnection (url, "myLogin", "myPassword");
Si uno de los drivers que hemos cargado reconoce la URL suministrada por el
mtodo DriverManager.getConnection, dicho driver establecer una conexin con
el controlador de base de datos especificado en la URL del JDBC. La
claseDriverManager, como su nombre indica, maneja todos los detalles del
establecimiento de la conexin detrs de la escena. A menos que estemos
escribiendo un driver, posiblemente nunca utilizaremos ningn mtodo del interface
Driver.
La conexin devuelta por el mtodo DriverManager.getConnection es una conexin
abierta que se puede utilizar para crear sentencias JDBC que pasen nuestras
sentencias SQL al controlador de la base de datos.
Todas las operaciones que se realizan al administrar una base de datos se pueden
clasificar en dos categoras generales: Actualizaciones y Consultas. Dentro de las
Actualizaciones se encuentran todo lo relacionado con la modificacin de
entidades (tablas), como por ejemplo, "crear entidad", "modificar atributos",
"eliminar registro", etc. En cambio, dentro de las Consultas se encuentran todas las
consultas que se puedan realizar a la base de datos, por ejemplo: "Seleccionar un
registro de tal entidad", etc.
El objeto que se encarga de enviar las sentencias SQL al driver es el Statement. Al
objeto Statement se le debe indicar que mtodo de utilizar dependiendo del tipo de
sentencia SQL enviada (Actualizaciones o Consultas). Si la sentencia SQL es una
Actualizacin, entonces se utiliza el mtodo executeUpdate. Si la sentencia SQL es
una Consulta, entonces se utiliza el mtodo executeQuery.
Para crear el objeto Statement se debe invocar el mtodo createStatement dentro
del objeto del tipo Connection utilizado para conectarse a la base de datos.
La lnea de cdigo siguiente muestra cmo crear un objeto Statement
(donde con es un objeto del tipo Connection).
Statement stmt = con.createStatement ();
La lnea de cdigo siguiente muestra el objeto Statement ejecutando una sentencia
SQL para crear una tabla. [4]
TABLAS CREADAS EN MySQL
Facultad
IdFACULTAD
Nombre
Direccin
Telfono
Pgina
Siglas
Calificacin
F . I . S . E E. INDUSTRIAL
I
FACULTAD
DE INGENIERA EN SISTEMAS, ELECTRNICA
Carrera
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
IdCarrera
Nombre
Aos
Facultad_idFACULTAD
Estudiante_idEstudiant
es
Malla
Curricular
idMalla Curricular
Nombre
Crditos
Correquisitos
Niveles
Prerrequisitos
idNiveles
Carrera_idCarrera
Comisiones
Nombre
Carrera_Facultad_idFACU
idComisiones
Malla
LTAD Curricular_idMalla Curricular
Nombre
Malla
Curricular_Carrera_idCarrera
Descripcin Personal
Malla
idAdministrativo
Carrera_idCarrera
Curricular_Carrera_Facultad_idFACULTAD
Nombre
Carrera_Facultad_idFACU
Estudiant Domicilio
LTAD
Dependencia
e
Telfono
idCargos
idEstudiant Correo Electrnico
Nombre
Administrativocol
es
Ubicacin
Periodo de Labores
Nombre
Personal_has_Dependenc
Direccin Titulacin
ia
Aos de Experiencia
Telfono
Personal_idAdministrativo
Estado Civil
Email
Dependecia_idCargos
EstudiantecPersonalcol
Carrera_idCarrera
ol
2.7
Resultados y Discusin
Carrera_Facultad_idFACULTA
El
modelo
de
datos
creado
en
D
WorkBench, fue analizado con las
Carrera_Estudiante_idEstudi
reglas
de normalizacin de bases de datos.
Como
ya se conoce, para eliminar la
antes
redundancia, posibles errores y
optimizar espacio en el disco.
El espacio fsico de la base de datos fue creado en PhpMyAdmin, con la IP
otorgada por el docente director de proyecto a cada alumno con su propio usuario
y contrasea, se realiz la conexin por medio de la red FISEI de la facultad.
El cdigo creado en lenguaje JAVA por medio de NetBeans, permite una
visualizacin de los datos insertados en la Base, permitiendo consultas
personalizadas y generales.
2.8 Conclusiones
El modelo de base de datos realizado para el proyecto es una ejecucin en
funcin de la estructura estudiantil que lleva la Facultad de Ingeniera en
Sistemas, Electrnica e Industrial de la Universidad Tcnica de Ambato.
Tomando en cuenta que es un sistema que involucra relaciones unomuchos, muchos-uno muchos-muchos, por las relaciones que existen entre
materias, carreras, docentes, alumnos y autoridades, la normalizacin de la
base de datos es esencial para garantizar su correcto funcionamiento.
El espacio fsico de la base de datos fue creado y otorgado por el docente a
cada alumno con su propio usuario y contrasea. La direccin de la base
establecida es 172.21.123.65/phpMyAdmin. Siendo esta realizada por
medio de la red FISEI para poder acceder inalmbricamente desde
cualquier lugar dentro de la facultad.
La ventana de consultas realizada en NetBeans posee un cdigo otorgado
en un botn que se encarga verificar la conexin con la base de datos, en
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
Codigo:
AREAS:
ackage conexion;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
*
* @author DavidHerrera
*/
public class AREAS extends javax.swing.JFrame {
public AREAS() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
codigo = new javax.swing.JTextField();
nombre = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
tele = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("AREAS");
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
jLabel2.setText("Codigo");
jLabel3.setText("Nombre");
jLabel4.setText("INGRESE EL CODIGO DE LA CARRERA");
jButton1.setText("Registrar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout
layout
=
new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(67, 67, 67)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(64, 64, 64)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.TRAILING)
.addComponent(nombre,
javax.swing.GroupLayout.PREFERRED_SIZE,
106,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(codigo,
javax.swing.GroupLayout.PREFERRED_SIZE,
106,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(161, 161, 161)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addComponent(jButton1)
.addComponent(tele,
javax.swing.GroupLayout.PREFERRED_SIZE,
108,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(191, 191, 191)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(109, 109, 109)
.addComponent(jLabel4)))
.addContainerGap(54, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
.addGroup(layout.createSequentialGroup()
.addContainerGap(24, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel2)
.addComponent(codigo,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(nombre,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addGap(18, 18, 18)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED)
.addComponent(tele, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton1)
.addGap(27, 27, 27))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
test_conect con=new test_conect();
Connection reg= con.conexion();
String cod, nom, cd,tel,mail,dir;
String sql;
cod=codigo.getText();
nom=nombre.getText();
tel=tele.getText();
//INSERT INTO `AREAS`(`idAREAS`, `Nombre`, `CARRERAS_idCARRERAS`)
sql="INSERT
INTO
`AREAS`
(`idAREAS`,
`Nombre`,`CARRERAS_idCARRERAS`)VALUES (?,?,?)";
try {
PreparedStatement pst=reg.prepareStatement(sql);
pst.setString(1,cod);
pst.setString(2,nom);
pst.setString(3,tel);
int n=pst.executeUpdate();
if (n>0){
JOptionPane.showMessageDialog(null,"registrado con exito");
}
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
*
* @author DavidHerrera
*/
public class CARGOS extends javax.swing.JFrame {
public CARGOS() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
codigo = new javax.swing.JTextField();
nombre = new javax.swing.JTextField();
tele = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("CARGOS");
jLabel2.setText("Codigo");
jLabel3.setText("Nombre");
jLabel4.setText("Descripcin");
jButton1.setText("Ingresar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout
layout
=
new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
.addGroup(layout.createSequentialGroup()
.addGap(170, 170, 170)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(86, 86, 86)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addComponent(jLabel4)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.
Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(jLabel3)))
.addGap(47, 47, 47)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addComponent(jButton1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.
Alignment.LEADING, false)
.addComponent(codigo)
.addComponent(nombre)
.addComponent(tele,
javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)))))
.addContainerGap(69, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(codigo,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel2))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel3)
.addComponent(nombre,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel4)
.addComponent(tele, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRE
LATED)
.addComponent(jButton1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
test_conect con=new test_conect();
Connection reg= con.conexion();
String cod, nom, cd,tel,mail,dir;
String sql;
cod=codigo.getText();
nom=nombre.getText();
tel=tele.getText();
//INSERT INTO `CARGOS`(`idCARGOS`, `Nombre`, `Descripcin`) VALUES
sql="INSERT INTO `CARGOS` (`idCARGOS`, `Nombre`,`Descripcin`)VALUES
(?,?,?)";
try {
PreparedStatement pst=reg.prepareStatement(sql);
pst.setString(1,cod);
pst.setString(2,nom);
pst.setString(3,tel);
int n=pst.executeUpdate();
if (n>0){
JOptionPane.showMessageDialog(null,"registrado con exito");
}
} catch (SQLException ex) {
Logger.getLogger(CARGOS.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default
look and feel.
*
For
details
see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(CARGOS.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(CARGOS.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(CARGOS.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(CARGOS.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CARGOS().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField codigo;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JTextField nombre;
private javax.swing.JTextField tele;
// End of variables declaration
}
CARRERAS:
package conexion;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
*
* @author DavidHerrera
*/
public class CARRERAS extends javax.swing.JFrame {
public CARRERAS() {
initComponents();
}
@SuppressWarnings("unchecked")
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
*
For
details
see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(CARRERAS.class.getName()).log(java.ut
il.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(CARRERAS.class.getName()).log(java.ut
il.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(CARRERAS.class.getName()).log(java.ut
il.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(CARRERAS.class.getName()).log(java.ut
il.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CARRERAS().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField codigo;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JTextField nombre;
// End of variables declaration
}
COMISIONES:
package conexion;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
*
* @author DavidHerrera
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
*/
public class COMISIONES extends javax.swing.JFrame {
/**
* Creates new form COMISIONES
*/
public COMISIONES() {
initComponents();
}
/**
* 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
codigo = new javax.swing.JTextField();
nombre = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("COMISIONES");
jLabel2.setText("Codigo");
jLabel3.setText("Nombre");
jButton1.setText("Registrarse");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout
layout
=
new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(69, 69, 69)
.addComponent(jLabel1)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(49, 49, 49)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addComponent(codigo)
.addComponent(nombre))))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(0, 65, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(62, 62, 62))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel2)
.addComponent(codigo,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel3)
.addComponent(nombre,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jButton1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
test_conect con=new test_conect();
Connection reg= con.conexion();
String cod, nom, cd,tel,mail,dir;
String sql;
cod=codigo.getText();
nom=nombre.getText();
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new COMISIONES().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField codigo;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JTextField nombre;
// End of variables declaration
}
ESTABLECER CONEXIN:
package conexion;
import java.sql.Connection;
import javax.swing.JOptionPane;
/**
*
* @author DavidHerrera
*/
public class Establecer_Conexion extends javax.swing.JFrame {
public Establecer_Conexion() {
initComponents();
this.setTitle("BASES DE DATOS DE UNIVERSIDADES");
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jMenuBar2 = new javax.swing.JMenuBar();
jMenu4 = new javax.swing.JMenu();
jMenu5 = new javax.swing.JMenu();
Universidades = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem2 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
jButton7.setText("Estudiantes");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
jButton8.setText("Comisiones");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
jMenu1.setText("Inicio");
jMenuItem2.setText("Salir");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2);
jMenuBar1.add(jMenu1);
jMenu2.setText("Ingresar");
jMenuItem4.setText("Universidades");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem4);
jMenuBar1.add(jMenu2);
jMenu3.setText("Conexion");
jMenuItem1.setText("Conectar");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem1);
jMenuBar1.add(jMenu3);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout
javax.swing.GroupLayout(getContentPane());
layout
new
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(Universidades)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.U
NRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.TRAILING)
.addComponent(jButton5)
.addComponent(jButton2)))
.addGroup(layout.createSequentialGroup()
.addGap(14, 14, 14)
.addComponent(jButton4)))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.R
ELATED)
.addComponent(jButton8))
.addGroup(layout.createSequentialGroup()
.addComponent(jButton6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.R
ELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton7)))
.addContainerGap(31, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(Universidades)
.addComponent(jButton2)
.addComponent(jButton3)
.addComponent(jButton8))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jButton4)
.addComponent(jButton5)
.addComponent(jButton6)
.addComponent(jButton7))
.addGap(61, 61, 61))
);
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
pack();
}// </editor-fold>
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
test_conect conec=new test_conect();
Connection con=conec.conexion();
if(con!=null){
JOptionPane.showMessageDialog(null, "conexion establecida");
}
else{
JOptionPane.showMessageDialog(null, "Error conexion");
}
}
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {
Formulario_Datos fd=new Formulario_Datos();
fd.setVisible(true);
}
private void UniversidadesActionPerformed(java.awt.event.ActionEvent evt) {
Formulario_Datos fd=new Formulario_Datos();
fd.setVisible(true);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
CARRERAS f2=new CARRERAS();
f2.setVisible(true);
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
FACULTAD f=new FACULTAD();
f.setVisible(true);
// TODO add your handling code here:
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
Formulario_Datos fd=new Formulario_Datos();
fd.setVisible(true);
// TODO add your handling code here:
}
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
Estudiantes f1=new Estudiantes();
f1.setVisible(true);
// TODO add your handling code here:
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
AREAS f3=new AREAS();
f3.setVisible(true);
// TODO add your handling code here:
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
Formulario_Datos fd=new Formulario_Datos();
fd.setVisible(true);
// TODO add your handling code here:
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
COMISIONES f4=new COMISIONES();
f4.setVisible(true);
// TODO add your handling code here:
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
}
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(WIDTH);
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default
look and feel.
*
For
details
see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Establecer_Conexion.class.getName()).l
og(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Establecer_Conexion.class.getName()).l
og(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Establecer_Conexion.class.getName()).l
og(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Establecer_Conexion.class.getName()).l
og(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Establecer_Conexion().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton Universidades;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
jLabel2.setText("Codigo");
jLabel3.setText("Nombre");
jLabel4.setText("Direccin");
jLabel5.setText("Telfono");
jButton1.setText("Enviar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout
layout
=
new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(158, 158, 158)
.addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(68, 68, 68)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5))
.addGap(38, 38, 38)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING, false)
.addComponent(codigo)
.addComponent(nombre)
.addComponent(direccion)
.addComponent(telefono, javax.swing.GroupLayout.DEFAULT_SIZE,
119, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED, 49, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(20, 20, 20))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
.addComponent(jLabel2)
.addComponent(codigo,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel3)
.addComponent(nombre,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel4)
.addComponent(direccion,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addComponent(jLabel5)
.addComponent(telefono,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(40, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.R
ELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(24, 24, 24))))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
test_conect con=new test_conect();
Connection reg= con.conexion();
String cod, nom, cd,tel,mail,cate,dir;
String sql;
cod=codigo.getText();
nom=nombre.getText();
dir=direccion.getText();
tel=telefono.getText();
//INSERT INTO `Estudiantes`(`idEstudiantes`, `Nombre`, `doreccion`, `telefono`)
VALUES ([value-1],[value-2],[value-3],[value-4])
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
sql="INSERT
INTO
`Estudiantes`
(`idEstudiantes`,
`Nombre`,`Doreccion`,`Telefono`)VALUES (?,?,?,?)";
try {
PreparedStatement pst=reg.prepareStatement(sql);
pst.setString(1,cod);
pst.setString(2,nom);
pst.setString(3,dir);
pst.setString(4,tel);
int n=pst.executeUpdate();
if (n>0){
JOptionPane.showMessageDialog(null,"registrado con exito");
}
} catch (SQLException ex) {
Logger.getLogger(Estudiantes.class.getName()).log(Level.SEVERE, null,
ex);
}
}
public static void main(String args[]) {
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default
look and feel.
*
For
details
see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Estudiantes.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Estudiantes.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Estudiantes.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Estudiantes.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Estudiantes().setVisible(true);
}
});
}
// Variables declaration - do not modify
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
jLabel3.setText("Direccin");
jLabel4.setText("Telefono");
jLabel5.setText("Email");
jLabel6.setText("Pagina web");
jLabel7.setText("Facultades");
jButton1.setText("Enviar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout
layout
=
new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addGap(67, 67, 67)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(jLabel7)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(codigo)
.addComponent(nombre)
.addComponent(direccion)
.addComponent(telefono)
.addComponent(email)
.addComponent(web, javax.swing.GroupLayout.DEFAULT_SIZE,
116, Short.MAX_VALUE)))
.addContainerGap(127, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(54, 54, 54))
);
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jLabel7)
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel1)
.addComponent(codigo,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRE
LATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel2)
.addComponent(nombre,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(1, 1, 1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel3)
.addComponent(direccion,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel4)
.addComponent(telefono,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel5)
.addComponent(email, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel6)
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
.addComponent(web, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jButton1)
.addContainerGap(40, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
test_conect con=new test_conect();
Connection reg= con.conexion();
String cod, nom, cd,tel,mail,dir;
String sql;
cod=codigo.getText();
nom=nombre.getText();
dir=direccion.getText();
tel=telefono.getText();
mail=email.getText();
cd=web.getText();
//INSERT INTO `FACULTADES`(`idFACULTADES`, `Nombre`, `Direccin`,
`Telefno`, `E-mail`, `Pagina web`) VALUES ([value-1],[value-2],[value-3],[value-4],
[value-5],[value-6])
sql="INSERT
INTO
`FACULTADES`
(`idFACULTADES`,
`Nombre`,`Direccin`,`Telefno`,`E-mail`,`Pagina web`)VALUES (?,?,?,?,?,?)";
try {
PreparedStatement pst=reg.prepareStatement(sql);
pst.setString(1,cod);
pst.setString(2,nom);
pst.setString(3,dir);
pst.setString(4,tel);
pst.setString(5,mail);
pst.setString(6,cd);
int n=pst.executeUpdate();
if (n>0){
JOptionPane.showMessageDialog(null,"registrado con exito");
}
} catch (SQLException ex) {
Logger.getLogger(FACULTAD.class.getName()).log(Level.SEVERE, null,
ex);
}
}
public static void main(String args[]) {
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default
look and feel.
*
For
details
see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(FACULTAD.class.getName()).log(java.util
.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(FACULTAD.class.getName()).log(java.util
.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(FACULTAD.class.getName()).log(java.util
.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(FACULTAD.class.getName()).log(java.util
.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FACULTAD().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField codigo;
private javax.swing.JTextField direccion;
private javax.swing.JTextField email;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JTextField nombre;
private javax.swing.JTextField telefono;
private javax.swing.JTextField web;
// End of variables declaration
}
FORMULARIO DATOS:
package conexion;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
/**
*
* @author DavidHerrera
*/
public class Formulario_Datos extends javax.swing.JFrame {
public Formulario_Datos() {
initComponents();
this.setTitle("Ingreso de Datos Universidades");
mostrardatosunviersidad();
}
void mostrardatosunviersidad(){
test_conect conec=new test_conect();
Connection con=conec.conexion();
DefaultTableModel modelouni=new DefaultTableModel();
modelouni.addColumn("Codigo");
modelouni.addColumn("Nombre");
modelouni.addColumn("Direccion");
modelouni.addColumn("Ciudad");
modelouni.addColumn("Telefono");
modelouni.addColumn("E-mail");
modelouni.addColumn("Categoria");
tabla_univer.setModel(modelouni);
String []datos_uni= new String[7];
try {
Statement stu=con.createStatement();
ResultSet resul_uni=stu.executeQuery("SELECT * FROM Universidad");
while(resul_uni.next()){
datos_uni[0]=resul_uni.getString(1);
datos_uni[1]=resul_uni.getString(2);
datos_uni[2]=resul_uni.getString(3);
datos_uni[3]=resul_uni.getString(4);
datos_uni[4]=resul_uni.getString(5);
datos_uni[5]=resul_uni.getString(6);
datos_uni[6]=resul_uni.getString(7);
modelouni.addRow(datos_uni);
}
tabla_univer.setModel(modelouni);
} catch (SQLException ex) {
Logger.getLogger(Formulario_Datos.class.getName()).log(Level.SEVERE,
null, ex);
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(u_ciud,
117,
.addComponent(jLabel7,
javax.swing.GroupLayout.PREFERRED_SIZE,
39,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.TRAILING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(u_cate,
javax.swing.GroupLayout.PREFERRED_SIZE,
43,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel5)
.addGap(18, 18, 18)
.addComponent(u_tel,
javax.swing.GroupLayout.PREFERRED_SIZE,
72,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(u_mail))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(jButton1)
.addComponent(jButton2))
.addGap(51, 51, 51))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(381, 381, 381)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(73, 73, 73)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
766,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(83, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jButton4)
.addGap(40, 40, 40)
.addComponent(jButton3)
.addGap(61, 61, 61))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(7, 7, 7)
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE,
14, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRE
LATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(u_nom,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(u_cod, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8)
.addComponent(u_cate,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jLabel5)
.addComponent(u_tel, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRE
LATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(u_dir, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(jLabel3)
.addComponent(u_ciud,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)
.addComponent(u_mail,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED, 39, Short.MAX_VALUE)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
118,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jButton3)
.addComponent(jButton4))
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
javax.swing.GroupLayout
layout
=
new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(111, 111, 111)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(58, 58, 58)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING, false)
.addComponent(jLabel2,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(43, 43, 43)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING, false)
.addComponent(codigo)
.addComponent(nombre,
javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addGap(97, 97, 97)
.addComponent(jButton1)))
.addContainerGap(43, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(jLabel2)
.addComponent(codigo,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE,
19,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(nombre,
javax.swing.GroupLayout.PREFERRED_SIZE,
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jButton1)
.addContainerGap(56, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
test_conect con=new test_conect();
Connection reg= con.conexion();
String cod, nom, cd,tel,mail,dir;
String sql;
cod=codigo.getText();
nom=nombre.getText();
//INSERT INTO `MALLA CURRICULAR`(`idMALLA CURRICULAR`, `Nombre`)
VALUES ([value-1],[value-2])
sql="INSERT INTO `MALLA CURRICULAR` (`idMALLA CURRICULAR`,
`Nombre`)VALUES (?,?)";
try {
PreparedStatement pst=reg.prepareStatement(sql);
pst.setString(1,cod);
pst.setString(2,nom);
int n=pst.executeUpdate();
if (n>0){
JOptionPane.showMessageDialog(null,"REGISTRO EXITOSO");
}
} catch (SQLException ex) {
Logger.getLogger(MALLA_CURRICULAR.class.getName()).log(Level.SEV
ERE, null, ex);
}
}
public static void main(String args[]) {
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default
look and feel.
*
For
details
see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MALLA_CURRICULAR.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
java.util.logging.Logger.getLogger(MALLA_CURRICULAR.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MALLA_CURRICULAR.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MALLA_CURRICULAR.class.getName())
.log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MALLA_CURRICULAR().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField codigo;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JTextField nombre;
// End of variables declaration
}
TEST CONEXIN:
package conexion;
import java.sql.*;
import javax.swing.JOptionPane;
/**
*
* @author Alexander
*/
public class test_conect {
Connection con=null;
public Connection conexion(){
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://172.21.123.65:3306/villago
mezdd","villagomezdd","villagomezdd");
System.out.println("conexion establecida");
} catch (ClassNotFoundException | SQLException e) {
System.out.println("error de conexion");
JOptionPane.showMessageDialog(null, "error de conexion "+e);
}
return con;
}
}
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016
F . I . S . E E. INDUSTRIAL
I
FACULTAD DE INGENIERA EN SISTEMAS, ELECTRNICA
PERODO ACADMICO: SEPTIEMBRE/2015 FEBRERO/2016