[ERROR AL EJECUTAR]
Publicado por Alejandra (17 intervenciones) el 06/11/2019 00:22:03
Buenas noches:
Me pasaron un programa hecho en Java, y al querer ejecutarlo en NETBEANS me sale error - no estoy pudiendo resolver - espero puedan ayudarme...
Este es el formulario de acceso al sistema:
El error que me muestra está en la línea 173... la variable stm conecta los objetos de la base de datos...
Me pasaron un programa hecho en Java, y al querer ejecutarlo en NETBEANS me sale error - no estoy pudiendo resolver - espero puedan ayudarme...
Este es el formulario de acceso al sistema:
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
package Formularios;
import java.sql.*;
import Base.ConectaBD;
import java.awt.Color;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;
public class FrmAcceso extends javax.swing.JFrame {
ConectaBD cnx = new ConectaBD();
int contador;
public void icono() {
Image icon = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Imagenes/031-usuario.png"));
setIconImage(icon);
setVisible(true);
}
public FrmAcceso() {
initComponents();
this.setLocationRelativeTo(this);
this.setResizable(false);
this.getContentPane().setBackground(Color.white);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
btncancelar = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
lblclave = new javax.swing.JLabel();
lblusuario = new javax.swing.JLabel();
psswdclave = new javax.swing.JPasswordField();
jTxtUsuario = new javax.swing.JTextField();
btningresar = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
btncancelar.setBackground(new java.awt.Color(0, 204, 255));
btncancelar.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N
btncancelar.setForeground(new java.awt.Color(0, 0, 204));
btncancelar.setText("CANCELAR");
btncancelar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btncancelarActionPerformed(evt);
}
});
jLabel5.setBackground(new java.awt.Color(0, 0, 255));
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/images.png"))); // NOI18N
jLabel5.setOpaque(true);
jLabel2.setFont(new java.awt.Font("Comic Sans MS", 1, 24)); // NOI18N
jLabel2.setForeground(new java.awt.Color(51, 51, 0));
jLabel2.setText("RESTAURANTE JHERSI'S");
lblclave.setFont(new java.awt.Font("Comic Sans MS", 1, 16)); // NOI18N
lblclave.setText("CONTRASEÑA:");
lblusuario.setFont(new java.awt.Font("Comic Sans MS", 1, 16)); // NOI18N
lblusuario.setText("USUARIO:");
psswdclave.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
psswdclave.setDisabledTextColor(new java.awt.Color(0, 0, 0));
psswdclave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
psswdclaveActionPerformed(evt);
}
});
jTxtUsuario.setFont(new java.awt.Font("Comic Sans MS", 0, 14)); // NOI18N
jTxtUsuario.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jTxtUsuarioKeyPressed(evt);
}
});
btningresar.setBackground(new java.awt.Color(0, 204, 255));
btningresar.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N
btningresar.setForeground(new java.awt.Color(0, 0, 204));
btningresar.setText("INGRESAR");
btningresar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btningresarActionPerformed(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()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(2, 2, 2)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblusuario, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(60, 60, 60)
.addComponent(jTxtUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblclave, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(20, 20, 20)
.addComponent(psswdclave, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(btningresar)
.addGap(51, 51, 51)
.addComponent(btncancelar))))
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(44, 44, 44))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblusuario, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTxtUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(10, 10, 10)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(lblclave))
.addComponent(psswdclave, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btningresar, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btncancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 16, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void btncancelarActionPerformed(java.awt.event.ActionEvent evt) {
int r;
r = JOptionPane.showConfirmDialog(null, "CERRAR PROGRAMA", "SALIR", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (r == JOptionPane.YES_OPTION) {
this.dispose();
}
}
private void psswdclaveActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void btningresarActionPerformed(java.awt.event.ActionEvent evt) {
try {
if (this.jTxtUsuario.getText().equals("") || this.psswdclave.getText().equals("")) {
JOptionPane.showMessageDialog(null, "Llenar Todos los campos");
return;
}
cnx.rs = cnx.stm.executeQuery("SELECT * FROM Usuario WHERE Nick='" + this.jTxtUsuario.getText() + "' AND clave='" + this.psswdclave.getText() + "'");
if (cnx.rs.next()) {
this.dispose();
FrmMenu_Sistema menu = new FrmMenu_Sistema();
menu.show();
} else {
JOptionPane.showMessageDialog(null, "Usuario o Contraseña Incorrectos", "Acceso Incorrecto", 0);
jTxtUsuario.setText("");
psswdclave.setText("");
// contador++;
// if (contador == 3) {
// JOptionPane.showConfirmDialog(null, "Intentos Superados", "Acceso Incorrecto", 0);
// cnx.rs = cnx.stm.executeQuery("UPDATE Usuario SET usuario='" + this.jTxtUsuario.getText() + "'");
// }
}
} catch (SQLException a) {
System.out.println(a.getMessage());
}
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
cnx.conectar();
icono();
}
private void jTxtUsuarioKeyPressed(java.awt.event.KeyEvent evt) {
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
this.psswdclave.requestFocus();
}
}
/**
* @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(FrmAcceso.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(FrmAcceso.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(FrmAcceso.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(FrmAcceso.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FrmAcceso().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btncancelar;
private javax.swing.JButton btningresar;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel5;
private javax.swing.JTextField jTxtUsuario;
private javax.swing.JLabel lblclave;
private javax.swing.JLabel lblusuario;
private javax.swing.JPasswordField psswdclave;
// End of variables declaration
}
El error que me muestra está en la línea 173... la variable stm conecta los objetos de la base de datos...
Valora esta pregunta


0