[ Foro de Java ]
Estoy siguiendo un ejemplo que conseguí en la red para modificar una base de datos, la conexión la hace adecuadamente y las opciones de BUSCA,MODIFICAR,Eliminar funcionan correctamente pero la de Guardar me envia el siguiente mensaje
run:
java.lang.IllegalArgumentException
y no guarda la información
Adjunto el código utilizado
estoy utilizando NetBeans 8.2 MySql y AMPPS
Mucho agradecería su orientación de en donde puedo estarme equivocando
package app;
import static app.conexion.getConection;
import com.mysql.jdbc.Connectio
import com.mysql.jdbc.ResultSet;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.swing.JOptionPane;
/**
*
* @author gpbrandi
*/
public class conexion extends javax.swing.JFrame {
public static final String URL = "jbdc:mysql://localhost:3306/Escuela";
public static final String USERNAME = "root";
public static final String PASSWORD = "mysql";
private static void cach() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public conexion() {
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() {
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("CONECTAR");
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(148, 148, 148)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(101, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(107, 107, 107)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(140, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
Connection con = null;
con = getConection();
PreparedStatement ps;
ResultSet res;
ps = con.prepareStatement("SELECT * FROM persona");
res = (ResultSet) ps.executeQuery();
if(res.next()){
JOptionPane.showMessageDialog(null, resgetString("nombre") + " " + res.getString("domicilio"));
} else {
JOptionPane.showMessageDialog(null,"No Existe Datos");
}
con.close();
} catch (SQLException ex) {
System.out.println(ex);
}
}
public static Connection getConection() throws SQLException {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.driver");
con = (Connection) DriverManager.getConnection(URL, USERNAME, PASSWORD);
JOptionPane.showMessageDialog(null, "Conexion EXITOSA");
} catch (ClassNotFoundException e) {
System.out.println(e);
}
return con;
}
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(conexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(conexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(conexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(conexion.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 conexion().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
// End of variables declaration
private String resgetString(String nombre) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)