Base de Datos Escuela
Base de Datos Escuela
Base de Datos Escuela
FUNDAMENTOS DE REDES
ALUMNO:
GRUPO: Z3
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
/**
* @author A515-51
*/
public conection() {
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
*/
@SuppressWarnings("unchecked")
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
btnConectar.setText("Conectar");
btnConectar.addActionListener(new java.awt.event.ActionListener() {
btnConectarActionPerformed(evt);
});
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(143, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(btnConectar)
.addContainerGap(141, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
try {
con = getConnection();
PreparedStatement ps;
ResultSet res;
res = ps.executeQuery();
if (res.next()) {
con.close();
} catch (Exception o) {
System.out.println(o);
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (Exception o) {
System.out.println(o);
return con;
//<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.
*/
try {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
java.util.logging.Logger.getLogger(conection.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
java.util.logging.Logger.getLogger(conection.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
java.util.logging.Logger.getLogger(conection.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
java.util.logging.Logger.getLogger(conection.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
new conection().setVisible(true);
});