5
I have the following question in Java: how can I pass to SQL that it should capture the "date and time" of the computer and update the User Table in Postgresql?
Follows code:
public class UsuarioAtualizar {
private Connection con = ConectarDB.getConexao();
private dao.UsuarioD daoUsuario = new dao.UsuarioD();
public void updateClienteByCpf(model.UsuarioM usuario){
// Variáveis
PreparedStatement ps = null;
String sql = "update usuario set timestamp=?";
// Inserção
try {
ps = con.prepareStatement(sql);
//ps.setString(1, usuario.getNome());
ps.executeUpdate();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
public dao.UsuarioD getDaoUsuario() {
return daoUsuario;
}
public void setDaoUsuario(dao.UsuarioD daoUsuario) {
this.daoUsuario = daoUsuario;
}
}
From the user’s computer? I think it is not possible, the database is installed on the server, there is no way he knows the time of the user’s pc. You should capture this via javascript and send it to your DAO, ai yes, save in sql.
– user28595
What runs on the customer’s computer? Can’t send the date in this User object?
– Ricardo
Done. User is on one pc and Server is on another. He wanted to be sent from the User to the Server his last access to register in the table. There is no way?
– Júnior Nascimento
How, but is an executable running on the client? Is it a website? Written on what? Because what you want should be put on the client system, not the server. Edit the question and place the client code that makes the call to the server by passing this User object
– Ricardo
It is a Java desktop application.
– Júnior Nascimento
I solved it. I must answer my own question?
– Júnior Nascimento
Absolutely! Your solution can help someone with the same problem as searching here :D.
– user28595
Thank you all!
– Júnior Nascimento