Code example for PreparedStatement

Methods: close, executeUpdate, setBoolean, setString

0
 
             
            this.con = getConexao();
            this.stmt = con.prepareStatement(sql);
//            this.stmt.setInt(1, api.getCodigo()); 
            this.stmt.setString(1, api.getUrlApi());
            this.stmt.setBoolean(2, api.getActive());
            this.stmt.setString(3, api.getUsuario());
            this.stmt.setString(4, api.getPassword());
            this.stmt.executeUpdate();
             
             
             
        }catch(SQLException e){
            throw new ApiSmsDAOException(e);
        }finally{ 
            if(stmt != null) stmt.close();
            if(con != null) con.close();
        } 
         
    }