Error al conectar con MySQL
Publicado por Darmask (1 intervención) el 21/11/2017 19:43:12
HOLA TENGO UN LOGIN CON CONEXION EN MYSQL PERO ME BOTA ESTE ERROR
Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.
at trabajofinal3.Conexion.getConnection(Conexion.java:56)
at trabajofinal3.Login.login(Login.java:136)
at trabajofinal3.Login.btnIniciarActionPerformed(Login.java:120)
at trabajofinal3.Login.access$000(Login.java:18)
at trabajofinal3.Login$1.actionPerformed(Login.java:72)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
EL CODIGO DEL LOGIN ES EL SIGUIENTE
ALGUIEN ME PUEDE AYUDAR
Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.
at trabajofinal3.Conexion.getConnection(Conexion.java:56)
at trabajofinal3.Login.login(Login.java:136)
at trabajofinal3.Login.btnIniciarActionPerformed(Login.java:120)
at trabajofinal3.Login.access$000(Login.java:18)
at trabajofinal3.Login$1.actionPerformed(Login.java:72)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
EL CODIGO DEL LOGIN ES EL SIGUIENTE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
package trabajofinal3;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author Darmask
*/
public class Login extends javax.swing.JFrame {
//Instancio la clase Postgres
private Conexion objMysql = new Conexion();
public Login() {
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() {
lblSesion = new javax.swing.JLabel();
lblUsuario = new javax.swing.JLabel();
lblContraseña = new javax.swing.JLabel();
txtNombre = new javax.swing.JTextField();
btnIniciar = new javax.swing.JButton();
txtPassword = new javax.swing.JPasswordField();
txtUsuario = new javax.swing.JLabel();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
mnuSalir = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Inicio Sesion");
setBackground(new java.awt.Color(255, 0, 0));
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
lblSesion.setFont(new java.awt.Font("FreeMono", 1, 18)); // NOI18N
lblSesion.setForeground(new java.awt.Color(255, 0, 0));
lblSesion.setText("Inicio De Sesion");
getContentPane().add(lblSesion, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 20, -1, -1));
lblUsuario.setFont(new java.awt.Font("DialogInput", 1, 14)); // NOI18N
lblUsuario.setForeground(new java.awt.Color(255, 255, 255));
lblUsuario.setText("Usuario :");
getContentPane().add(lblUsuario, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 80, -1, -1));
lblContraseña.setFont(new java.awt.Font("DialogInput", 1, 14)); // NOI18N
lblContraseña.setForeground(new java.awt.Color(255, 255, 255));
lblContraseña.setText("Contraseña :");
getContentPane().add(lblContraseña, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 150, -1, -1));
getContentPane().add(txtNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 80, 110, -1));
btnIniciar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/icono1.png.png"))); // NOI18N
btnIniciar.setText("Iniciar");
btnIniciar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnIniciarActionPerformed(evt);
}
});
getContentPane().add(btnIniciar, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 220, 70, 30));
getContentPane().add(txtPassword, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 160, 110, -1));
txtUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/fondo.jpg"))); // NOI18N
getContentPane().add(txtUsuario, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 6, 443, 288));
jMenu1.setText("Archivo");
mnuSalir.setText("Salir");
mnuSalir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mnuSalirActionPerformed(evt);
}
});
jMenu1.add(mnuSalir);
jMenuBar1.add(jMenu1);
setJMenuBar(jMenuBar1);
pack();
}// </editor-fold>
private void mnuSalirActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void btnIniciarActionPerformed(java.awt.event.ActionEvent evt) {
String usuario = txtNombre.getText();
String password = txtPassword.getText();
//VAlidacion de campos vacios
if(txtNombre.getText().equals("")){
JOptionPane.showMessageDialog(null,"Debe de Ingresar el Usuario");
txtUsuario.requestFocus();
return;
}
if(txtPassword.getText().equals("")){
JOptionPane.showMessageDialog(null, "Debe de Ingresar la Contraseña");
txtPassword.requestFocus();
return;
}
else{
try{
login(usuario , password);
}catch(SQLException ex){
JOptionPane.showMessageDialog(null, ex);
}
}
}
public void login(String usuario , String password) throws SQLException{
String SQL;
String tipoUsuario="";
Conexion con = new Conexion();
Connection cnn = con.getConnection();
SQL="SELECT * FROM usuarios WHERE usuario ='"+usuario+"' AND pass ='"+password+"'";
Statement st = cnn.createStatement();
ResultSet rs = st.executeQuery(SQL);
while(rs.next()){
tipoUsuario = rs.getString("tipoUsuario");
}
if(tipoUsuario.equals("administrador")){
ReporteVentas obj = new ReporteVentas();
obj.setVisible(true);
this.dispose();
}
if(tipoUsuario.equals("supervisor")){
Supervisor obj = new Supervisor();
obj.setVisible(true);
this.dispose();
}
txtNombre.setText("");
txtPassword.setText("");
txtNombre.requestFocus();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Login().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnIniciar;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JLabel lblContraseña;
private javax.swing.JLabel lblSesion;
private javax.swing.JLabel lblUsuario;
private javax.swing.JMenuItem mnuSalir;
private javax.swing.JTextField txtNombre;
public javax.swing.JPasswordField txtPassword;
private javax.swing.JLabel txtUsuario;
// End of variables declaration
}
Valora esta pregunta


0