0% found this document useful (0 votes)
24 views2 pages

Public Variables Eliminarcustomer

The document describes Java methods for eliminating, consulting, modifying, and clearing customer data from a database. It contains code to connect to the database, execute prepared SQL statements, and return results or messages.

Uploaded by

cm5442621
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Public Variables Eliminarcustomer

The document describes Java methods for eliminating, consulting, modifying, and clearing customer data from a database. It contains code to connect to the database, execute prepared SQL statements, and return results or messages.

Uploaded by

cm5442621
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

}

public variables eliminarCustomer() {


DataCliente conexion = new DataCliente();
Connection cn = null;

PreparedStatement pstm = null;

try {
cn = conexion.conectar();
String query = "DELETE FROM cliente.cliente WHERE
id=?";
pstm = cn.prepareStatement(query);
pstm.setString(1, variables.id);
pstm.executeUpdate();
JOptionPane.showMessageDialog(null,"Cliente
eliminado");
} catch (SQLException e2) {
e2.printStackTrace();
JOptionPane.showMessageDialog(null,"Error");
}
return var;

}
public variables consultarCustomer() {
DataCliente conexion = new DataCliente();
Connection cn = null;

PreparedStatement pstm = null;


ResultSet rs=null;

try {
cn = conexion.conectar();
String query = "SELECT * FROM cliente.cliente
WHERE id=?";
pstm = cn.prepareStatement(query);
pstm.setString(1, variables.id);
rs=pstm.executeQuery();
if(rs.next()==true) {
JOptionPane.showMessageDialog(null, "Cliente
encontrado");
variables.setId(rs.getString("id"));
variables.setName(rs.getString("name"));
variables.setCia(rs.getString("cia"));
}else {
JOptionPane.showMessageDialog(null,
"Error");
}

}catch (SQLException e2) {


e2.printStackTrace();
JOptionPane.showMessageDialog(null, "Error");
}
return var;

}
public variables modificarCustomer() {
DataCliente conexion = new DataCliente();
Connection cn = null;

PreparedStatement pstm = null;

try {
cn = conexion.conectar();
String query = "UPDATE cliente.cliente SET name=?,
cia=? WHERE id=?";
pstm = cn.prepareStatement(query);
pstm.setString(1, variables.name);
pstm.setString(2, variables.cia);
pstm.setString(3, variables.id);
pstm.executeUpdate();
JOptionPane.showMessageDialog(null, "Cliente
modificado");
}catch (SQLException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Error");
}
return var;
}
public void Limpiar() {
variables.name="";
variables.cia="";
variables.id="";

You might also like