Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void atualizar(BeanCursoJsp beanCursoJsp) {
- try {
- StringBuilder sqlBuilder = new StringBuilder("UPDATE usuario SET login = ?, senha = ?, nome = ?, cep = ?, rua = ?, bairro = ?, cidade = ?, uf = ?, ibge = ?, fotobase64 = ?, contenttype = ?, curriculobase64 = ?, contenttypecurriculo = ?");
- boolean isMiniaturaFoto = beanCursoJsp.getMiniaturaFoto() != null && !beanCursoJsp.getMiniaturaFoto().isEmpty();
- if (isMiniaturaFoto) sqlBuilder.append(", fotominiatura = ?");
- sqlBuilder.append(" WHERE id = ").append(beanCursoJsp.getId());
- String sql = sqlBuilder.toString();
- try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setString(1, beanCursoJsp.getLogin());
- preparedStatement.setString(2, beanCursoJsp.getSenha());
- preparedStatement.setString(3, beanCursoJsp.getNome());
- preparedStatement.setString(4, beanCursoJsp.getCep());
- preparedStatement.setString(5, beanCursoJsp.getRua());
- preparedStatement.setString(6, beanCursoJsp.getBairro());
- preparedStatement.setString(7, beanCursoJsp.getCidade());
- preparedStatement.setString(8, beanCursoJsp.getEstado());
- preparedStatement.setString(9, beanCursoJsp.getIbge());
- preparedStatement.setString(10, beanCursoJsp.getFoto());
- preparedStatement.setString(11, beanCursoJsp.getContentType());
- preparedStatement.setString(12, beanCursoJsp.getCurriculoBase64());
- preparedStatement.setString(13, beanCursoJsp.getContentTypeCurriculo());
- if (isMiniaturaFoto) preparedStatement.setString(14, beanCursoJsp.getMiniaturaFoto());
- preparedStatement.executeUpdate();
- }
- connection.commit();
- } catch (Exception e) {
- e.printStackTrace();
- try {
- connection.rollback();
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment