)
Código:
bueno se que en SQL se elimina un registro con DELETE FROM "nombretabla" where "condicion" y que para actualizar es: UPDATE FROM bla bla bla... bueno alguien tiene alguna idea de como agregar estas funciones? private void agrega(ActionEvent e) {
areaTexto.setText("");
Connection c = null;
Statement s = null;
ResultSet rs = null;
String nombre = null;
String direccion = null;
String telefono = null;
String email = null;
String website = null;
nombre = campo1.getText();
direccion = campo2.getText();
telefono = campo3.getText();
email = campo4.getText();
website = campo5.getText();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c = DriverManager.getConnection("jdbc:odbc:bdagenda","guest","guest");
} catch( ClassNotFoundException cnfe){
areaTexto.setText("Error al cargar driver JDBC\n");
cnfe.printStackTrace();
} catch( SQLException sqle){
areaTexto.setText("No se puede conectar la base de datos\n");
}
try {
s=c.createStatement();
s.executeUpdate("INSERT INTO bdagenda \nVALUES (" + //Aqui es donde tengo el problema!!
"'" + nombre + "', " + "'" + direccion + "', " +
"'" + telefono + "', " + "'" + email + "', " + "'" + website + "')");
rs = s.executeQuery("select * from bdagenda");
rs.next();
do{
areaTexto.append( rs.getString("NOMBRE") + "\n~" +
rs.getString("DOMICILIO") +"\n~" +
rs.getString("TELEFONO") + "\n~" +
rs.getString("EMAIL") + "\n~" +
rs.getString("WEBSITE") + "\n****************************************************\n" );
} while(rs.next());
s.close();
c.close();
} catch( SQLException sqle){
areaTexto.setText("Excepción de SQL\n");
sqle.printStackTrace();
}
campo1.setText("");
campo2.setText("");
campo3.setText("");
campo4.setText("");
campo5.setText("");
}
se supone que son botones

